Using Sonar Cloud in VSTS CI task

142 views
Skip to first unread message

anandjit banerjee

unread,
May 18, 2018, 6:57:56 AM5/18/18
to SonarQube
We have been trying to sonar cloud to run as a CI task for our codebase in VSTS.However it fails with error message as :

is not a valid branch name. The allowed format is the same as for Git branches.

Can someone please help on this.

G. Ann Campbell

unread,
May 18, 2018, 8:01:45 AM5/18/18
to SonarQube
Hi,

There's not enough information here for anyone to help you. What branch name is included in your error message? What parameters to you pass to analysis? 


Ann

P.S. The standard courtesies (Hi, Thanks, ...) are appreciated in this group.

parul.t...@nielsen.com

unread,
May 18, 2018, 8:13:33 AM5/18/18
to SonarQube
Issue with "Integrating SonarQube Cloud with VSTS using TFVC for Xamarin Android Project" 

For static code analysis , I am trying to integrate Sonar Cloud with VSTS. I have created the project in Sonar Cloud and added the same using Prepare Analysis step. The build fails at the Run Code Analysis step. Please see below the steps that I have added to automate build for Xamarin Android Code.

1. Use NuGet 4.5.1

2.NUGet Restore

3. Prepare Analysis Step for Sonar Cloud

4. Build Xamarin Android Project

5. VS test assemblies

6.Run Code Analysis ( Build Fails)

7. Signing and aligning the Apk

Though without the Sonar Cloud integration, the build works fine.



I am getting the following error

Error : 2018-05-15T11:48:11.3238514Z INFO: EXECUTION FAILURE 2018-05-15T11:48:11.3238826Z INFO: ------------------------------------------------------------------------ 2018-05-15T11:48:11.3239034Z INFO: Total time: 42.119s 2018-05-15T11:48:11.4108992Z ERROR: Error during SonarQube Scanner execution 2018-05-15T11:48:11.4109761Z ERROR: Validation of project reactor failed: 2018-05-15T11:48:11.4110149Z o "$/ABC/Sonar-branch" is not a valid branch name. The allowed format is the same as for Git branches. See https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html 2018-05-15T11:48:11.4110481Z ERROR: 2018-05-15T11:48:11.4110731Z ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging. 2018-05-15T11:48:11.4111028Z INFO: Final Memory: 15M/111M 2018-05-15T11:48:11.4111281Z INFO: ------------------------------------------------------------------------ 2018-05-15T11:48:11.5024850Z The SonarQube Scanner did not complete successfully 2018-05-15T11:48:11.5088067Z 11:48:11.507 Creating a summary markdown file... 2018-05-15T11:48:11.5101821Z 11:48:11.509 Post-processing failed. Exit code: 1 2018-05-15T11:48:11.5302156Z ##[error]D:\a_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.2.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe failed with return code: 1 2018-05-15T11:48:11.5346163Z ##[section]Finishing: Run Code Analysis

Please suggest what needs to be done. I am not able to resolve this.

janos....@sonarsource.com

unread,
May 18, 2018, 9:55:56 AM5/18/18
to SonarQube
Hi,

It seems the name of the branch in your build is this: $/ABC/Sonar-branch

The error message says this name is not in a valid format, but that's not true. This name is indeed allowed, and I copy pasted from your output to verify this is indeed the case.

Is this really the name of the branch or have you modified the output to remove private info? It seem it's not the real name, and you have something in the real name that makes it not valid. Try to use a simpler name.

Cheers,
Janos

Parul Tripathi

unread,
May 18, 2018, 10:07:10 AM5/18/18
to janos....@sonarsource.com, SonarQube
Thanks Janos for investigating this

You are right. That is not the correct branch name. 
The branch name is something like 

$/DCT Xamarin/Sonar-branch/DCT/DCT.Droid/DigitalCollectionTool.Droid.csproj

I am also attaching the logs and the screen shots for the steps I had followed to integrate Sonar cloud.

Thanks
Parul

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/ElRzkg7BVmg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/3e62d410-f168-4418-ae36-e1aea934a292%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

logs_1549.zip
XamarinVSTSSonarCloudIntegration.pdf

Janos Gyerik

unread,
May 18, 2018, 10:22:36 AM5/18/18
to Parul Tripathi, SonarQube
That's not a valid branch name: $/DCT Xamarin/Sonar-branch/DCT/DCT.Droid/DigitalCollectionTool.Droid.csproj

It becomes valid if you remove the space. But it's a very strange name for a branch, and you probably did not intend that way. Let's see how we can fix that.

It seems the Xamarin project name because the branch name by default. And the current value looks like a path to a file. I'm talking about the value of Project in the Build Xamarin step. I suggest to change it to something more natural.

Most importantly, in the Project analysis on SonarCloud step, in the Additional Properties box, add a line like this:

sonar.branch.name=$(Build.SourceBranchName)

I think this should fix the problem. If you still get an error, please again send the relevant error output.

Cheers,
Janos
--

Janos Gyerik | SonarSource

Software Developer

http://sonarsource.com


Are you using SonarLint in your IDE?

Parul Tripathi

unread,
May 18, 2018, 11:08:14 AM5/18/18
to Janos Gyerik, SonarQube
Thanks a ton Janos ..... 


It finally worked ,,,,, 

Thanks for pointing in the right direction. I had been struggling with this for quite sometime.

Thank you 

Reply all
Reply to author
Forward
0 new messages