Thanks. The first thing I recommend checking then is that the SonarQube task (and the build definition that contains it) is only triggered on master branch. Community Edition does not support analysis of branches, so you need to make sure that SonarQube analysis only is performed on master (weāve took a note here to make the documentation a little bit clearer in that aspect).
The current logic is that it looks at the Build.SourceBranch variable in TFS/VSTS environment (if youāre curious you can see the code logic here). For Git if itās anything else then refs/heads/master then it will set sonar.branch.name, resulting in a failure if Community Edition is in use.
By the way before anything do make sure to run latest version of the SonarQube Extension : v4.3.2 as of writing.
After uninstalling cxx community pluging version 0.9.7 it looks my problems are solved! No CxxCoverageSensor problem and no sonar.branch problem with the first project i tried. Upgrading the SonarQube extension to version 4.3.2 was the solution. Thanks!
Hello we are running into the same problem of sonar.branch.name in a Azure DevOps (aKa VSTS) with Git + .NET solution on a non default branch (when run in default branch it works),
We are using v4.3.2 of SonarQube plugin and SonarQube 7.3 community edition, here goes the log for the prepare Analysis with diagnostics logs enabled:
2018-09-27T07:37:47.9353206Z ##[debug]Evaluating condition for step: 'Prepare analysis on SonarQube'
2018-09-27T07:37:47.9354072Z ##[debug]Evaluating: succeeded()
2018-09-27T07:37:47.9354420Z ##[debug]Evaluating succeeded:
2018-09-27T07:37:47.9354857Z ##[debug]=> True
2018-09-27T07:37:47.9355551Z ##[debug]Result: True
2018-09-27T07:37:47.9355920Z ##[section]Starting: Prepare analysis on SonarQube
2018-09-27T07:37:47.9360665Z ==============================================================================
2018-09-27T07:37:47.9360897Z Task : Prepare Analysis Configuration
2018-09-27T07:37:47.9361127Z Description : Prepare SonarQube analysis configuration
2018-09-27T07:37:47.9361304Z Version : 4.3.2
2018-09-27T07:37:47.9361482Z Author : sonarsource
2018-09-27T07:37:47.9362126Z ==============================================================================
2018-09-27T07:37:48.1755273Z ##[debug]agent.TempDirectory=D:\a\_temp
2018-09-27T07:37:48.1794152Z ##[debug]loading inputs and endpoints
2018-09-27T07:37:48.1803669Z ##[debug]loading ENDPOINT_AUTH_ee00d041-1fb6-462f-969a-94ac2ccd777b
2018-09-27T07:37:48.1816476Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_ee00d041-1fb6-462f-969a-94ac2ccd777b_USERNAME
2018-09-27T07:37:48.1818740Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2018-09-27T07:37:48.1820901Z ##[debug]loading ENDPOINT_AUTH_SCHEME_ee00d041-1fb6-462f-969a-94ac2ccd777b
2018-09-27T07:37:48.1822539Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2018-09-27T07:37:48.1824133Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2018-09-27T07:37:48.1826984Z ##[debug]loading INPUT_CLIPROJECTVERSION
2018-09-27T07:37:48.1829674Z ##[debug]loading INPUT_CLISOURCES
2018-09-27T07:37:48.1832561Z ##[debug]loading INPUT_CONFIGFILE
2018-09-27T07:37:48.1835976Z ##[debug]loading INPUT_CONFIGMODE
2018-09-27T07:37:48.1838519Z ##[debug]loading INPUT_EXTRAPROPERTIES
2018-09-27T07:37:48.1840037Z ##[debug]loading INPUT_PROJECTKEY
2018-09-27T07:37:48.1841441Z ##[debug]loading INPUT_PROJECTNAME
2018-09-27T07:37:48.1844693Z ##[debug]loading INPUT_PROJECTVERSION
2018-09-27T07:37:49.0525719Z ##[debug]loading INPUT_SCANNERMODE
2018-09-27T07:37:49.0532624Z ##[debug]loading INPUT_SONARQUBE
2018-09-27T07:37:49.0533146Z ##[debug]loaded 16
2018-09-27T07:37:49.0533612Z ##[debug]Agent.ProxyUrl=undefined
2018-09-27T07:37:49.0533905Z ##[debug]Agent.CAInfo=undefined
2018-09-27T07:37:49.0534190Z ##[debug]Agent.ClientCert=undefined
2018-09-27T07:37:49.0534558Z ##[debug]Agent.SkipCertValidation=undefined
2018-09-27T07:37:49.0534831Z ##[debug]SonarQube=ee00d041-1fb6-462f-969a-94ac2ccd777b
2018-09-27T07:37:49.0535112Z ##[debug]ee00d041-1fb6-462f-969a-94ac2ccd777b=(link)XXXXXXXXX/
2018-09-27T07:37:49.0535451Z ##[debug]ee00d041-1fb6-462f-969a-94ac2ccd777b auth param apitoken = null
2018-09-27T07:37:49.0535879Z ##[debug]ee00d041-1fb6-462f-969a-94ac2ccd777b auth param username = ***
2018-09-27T07:37:49.0536205Z ##[debug]ee00d041-1fb6-462f-969a-94ac2ccd777b auth param password = null
2018-09-27T07:37:49.0536487Z ##[debug]organization=null
2018-09-27T07:37:49.0536739Z ##[debug]scannerMode=MSBuild
2018-09-27T07:37:49.0536979Z ##[debug]projectKey=XXXXXXXXX
2018-09-27T07:37:49.0537240Z ##[debug]projectName=XXXXXXXXX
2018-09-27T07:37:49.0537485Z ##[debug]projectVersion=1.0
2018-09-27T07:37:49.0537743Z ##[debug][SQ] API GET: '/api/server/version' with query "undefined"
2018-09-27T07:37:49.0538277Z ##[debug]Response: 200 Body: "7.3.0.15553"
2018-09-27T07:37:49.0538553Z ##[debug]System.TeamFoundationCollectionUri=(link)alejandria.visualstudio.com/
2018-09-27T07:37:49.0538842Z ##[debug]System.PullRequest.PullRequestId=undefined
2018-09-27T07:37:49.0539105Z ##[debug]Build.Repository.Provider=TfsGit
2018-09-27T07:37:49.0539355Z ##[debug]Build.SourceBranch=refs/heads/develop
2018-09-27T07:37:49.0539540Z SYSTEMVSSCONNECTION exists true
2018-09-27T07:37:49.0541012Z ##[debug]SYSTEMVSSCONNECTION exists true
2018-09-27T07:37:49.1286142Z ##[debug]Build.Repository.Name=Azure Functions SISNet ALM
2018-09-27T07:37:49.1286700Z ##[debug]System.TeamProject=Azure Functions SISNet ALM
2018-09-27T07:37:49.2098943Z ##[debug]Default branch of this repository is 'refs/heads/master'
2018-09-27T07:37:49.2099667Z ##[debug]Build.SourceBranch=refs/heads/develop
2018-09-27T07:37:49.2101983Z ##[debug][SQ] Branch and PR parameters: {"sonar.branch.name":"develop"}
2018-09-27T07:37:49.2105534Z ##[debug]extraProperties=# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
2018-09-27T07:37:49.2125733Z ##[debug]set SONARQUBE_SCANNER_MODE=MSBuild
2018-09-27T07:37:49.2126306Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MODE;issecret=false;]MSBuild
2018-09-27T07:37:49.2126602Z ##[debug]set SONARQUBE_ENDPOINT=********
2018-09-27T07:37:49.2127933Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_ENDPOINT;issecret=true;]***
2018-09-27T07:37:49.2145642Z ##[debug]set SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"(link)XXXXXXXXX/","sonar.login":***,"sonar.projectKey":"XXXXXXXXX","sonar.projectName":"XXXXXXXXX","sonar.projectVersion":"1.0","sonar.branch.name":"develop"}
2018-09-27T07:37:49.2147174Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS;issecret=false;]{"sonar.host.url":"(link)XXXXXXXXX/","sonar.login":***,"sonar.projectKey":"XXXXXXXXX","sonar.projectName":"XXXXXXXXX","sonar.projectVersion":"1.0","sonar.branch.name":"develop"}
2018-09-27T07:37:49.2158396Z ##[debug]Absolute path for pathSegments: D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2,classic-sonar-scanner-msbuild,SonarScanner.MSBuild.exe = D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2018-09-27T07:37:49.2159018Z ##[debug]Using classic scanner at D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2018-09-27T07:37:49.2159492Z ##[debug]set SONARQUBE_SCANNER_MSBUILD_EXE=D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2018-09-27T07:37:49.2160363Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MSBUILD_EXE;issecret=false;]D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2018-09-27T07:37:49.2162774Z ##[debug]which 'D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2018-09-27T07:37:49.2170626Z ##[debug]found: 'D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2018-09-27T07:37:49.2171226Z ##[debug]which 'D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2018-09-27T07:37:49.2171776Z ##[debug]found: 'D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2018-09-27T07:37:49.2174008Z ##[debug]D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: begin
2018-09-27T07:37:49.2174638Z ##[debug]D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: /k:XXXXXXXXX
2018-09-27T07:37:49.2176243Z ##[debug]system.debug=true
2018-09-27T07:37:49.2176831Z ##[debug]D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: /d:sonar.verbose=true
2018-09-27T07:37:49.2184778Z ##[debug]exec tool: D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2018-09-27T07:37:49.2185943Z ##[debug]arguments:
2018-09-27T07:37:49.2186304Z ##[debug] begin
2018-09-27T07:37:49.2186763Z ##[debug] /k:XXXXXXXXX
2018-09-27T07:37:49.2187137Z ##[debug] /d:sonar.verbose=true
2018-09-27T07:37:49.2194856Z [command]D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:XXXXXXXXX /d:sonar.verbose=true
2018-09-27T07:37:49.2813855Z SonarScanner for MSBuild 4.3.1
2018-09-27T07:37:49.2815031Z Using the .NET Framework version of the Scanner for MSBuild
2018-09-27T07:37:49.3353942Z Default properties file was found at D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2018-09-27T07:37:49.3354658Z Loading analysis properties from D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2018-09-27T07:37:49.3355150Z sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2018-09-27T07:37:49.3356830Z Pre-processing started.
2018-09-27T07:37:49.3374124Z Preparing working directories...
2018-09-27T07:37:49.3381122Z Using environment variables to determine the download directory...
2018-09-27T07:37:49.3387510Z Using environment variable 'AGENT_BUILDDIRECTORY', value 'D:\a\1'
2018-09-27T07:37:49.3399675Z Creating directory: D:\a\1\.sonarqube
2018-09-27T07:37:49.4106823Z 07:37:49.409 07:37:49.402 Loading analysis properties from D:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.3.2\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2018-09-27T07:37:49.4107737Z 07:37:49.409 07:37:49.409 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2018-09-27T07:37:49.4168807Z 07:37:49.416 Updating build integration targets...
2018-09-27T07:37:49.4243408Z 07:37:49.423 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
2018-09-27T07:37:49.4286677Z 07:37:49.427 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
2018-09-27T07:37:49.4382003Z 07:37:49.437 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
2018-09-27T07:37:49.4422169Z 07:37:49.441 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
2018-09-27T07:37:49.4463165Z 07:37:49.445 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
2018-09-27T07:37:49.4505691Z 07:37:49.449 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
2018-09-27T07:37:49.4513815Z 07:37:49.45 Installed SonarQube.Integration.targets to D:\a\1\.sonarqube\bin\targets
2018-09-27T07:37:49.4526975Z 07:37:49.452 Creating config and output folders...
2018-09-27T07:37:49.4529972Z 07:37:49.452 Creating directory: D:\a\1\.sonarqube\conf
2018-09-27T07:37:49.4541082Z 07:37:49.452 Creating directory: D:\a\1\.sonarqube\out
2018-09-27T07:37:49.4617002Z 07:37:49.46 Fetching analysis configuration settings...
2018-09-27T07:37:49.4647981Z 07:37:49.464 Downloading from (link)XXXXXXXXX/api/server/version...
2018-09-27T07:37:49.6454642Z 07:37:49.644 Fetching properties for project 'XXXXXXXXX' from (link)XXXXXXXXX/api/settings/values?component=XXXXXXXXX...
2018-09-27T07:37:49.6462213Z 07:37:49.645 Downloading from (link)XXXXXXXXX/api/settings/values?component=XXXXXXXXX...
2018-09-27T07:37:49.7041300Z 07:37:49.703 Downloading from (link)XXXXXXXXX/api/languages/list...
2018-09-27T07:37:49.7299017Z 07:37:49.728 Fetching quality profile for project 'XXXXXXXXX' from (link)XXXXXXXXX/api/qualityprofiles/search?projectKey=XXXXXXXXX...
2018-09-27T07:37:49.7311400Z 07:37:49.73 Downloading from (link)XXXXXXXXX/api/qualityprofiles/search?projectKey=XXXXXXXXX...
2018-09-27T07:37:49.7904210Z 07:37:49.789 Fetching active rules for quality profile 'cs-sonar-way-87990' from (link)XXXXXXXXX/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile=cs-sonar-way-87990&p=1...
2018-09-27T07:37:49.7910994Z 07:37:49.79 Downloading from (link)XXXXXXXXX/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile=cs-sonar-way-87990&p=1...
2018-09-27T07:37:49.8909559Z 07:37:49.889 Fetching rules not active in quality profile 'cs-sonar-way-87990' for language 'cs' from (link)XXXXXXXXX/api/rules/search?f=internalKey&ps=500&activation=false&qprofile=cs-sonar-way-87990&p=1&languages=cs...
2018-09-27T07:37:49.8912529Z 07:37:49.89 Downloading from (link)XXXXXXXXX/api/rules/search?f=internalKey&ps=500&activation=false&qprofile=cs-sonar-way-87990&p=1&languages=cs...
2018-09-27T07:37:49.9422216Z 07:37:49.941 Local analyzer cache: C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources
2018-09-27T07:37:49.9529001Z 07:37:49.952 Writing Roslyn generated ruleset to D:\a\1\.sonarqube\conf\SonarQubeRoslyn-cs.ruleset...
2018-09-27T07:37:49.9696584Z 07:37:49.968 Writing Roslyn analyzer additional file to D:\a\1\.sonarqube\conf\cs\SonarLint.xml...
2018-09-27T07:37:49.9728699Z 07:37:49.972 Provisioning analyzer assemblies for cs...
2018-09-27T07:37:49.9739162Z 07:37:49.973 Installing required Roslyn analyzers...
2018-09-27T07:37:49.9746720Z 07:37:49.973 Processing plugin: csharp version 7.5.0.6605
2018-09-27T07:37:50.1020613Z 07:37:50.101 Cache miss: plugin files were not found in the local cache
2018-09-27T07:37:51.7243663Z 07:37:51.723 Fetching resource for plugin: csharp, version 7.5.0.6605. Resource: SonarAnalyzer-7.5.0.6605.zip
2018-09-27T07:37:51.7253783Z 07:37:51.724 Downloading SonarAnalyzer-7.5.0.6605.zip from (link)XXXXXXXXX/static/csharp/SonarAnalyzer-7.5.0.6605.zip to C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\0
2018-09-27T07:37:51.7258832Z 07:37:51.724 Downloading file from (link)XXXXXXXXX/static/csharp/SonarAnalyzer-7.5.0.6605.zip to C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer-7.5.0.6605.zip...
2018-09-27T07:37:51.8993088Z 07:37:51.898 Extracting files to C:\Users\VssAdministrator\AppData\Local\Temp\.sonarqube\resources\0...
2018-09-27T07:37:51.9715566Z 07:37:51.97 Pre-processing succeeded.
2018-09-27T07:37:51.9791758Z ##[debug]rc:0
2018-09-27T07:37:51.9792461Z ##[debug]success:true
2018-09-27T07:37:51.9909355Z ##[section]Finishing: Prepare analysis on SonarQube
Community Edition only works on the default Master branch. Interestingly, I changed the default branch from master to develop and it SonarQube stopped working until I changed the default branch back to master.
Yes, I think it was a change implemented with 7.0. We are using Azure DevOps so all I had to do was add a condition so that the Sonar tasks only run on the master branch.
Hello Guys, the only method to fix this issue is setting as default branch where you want generate a Build.(project settings-> code -> repositories --> branches -> right clic on the named branch -> set as default -> then run build pipeline).
I set the default project in VSTS as ādevelopā. The code analysis passed but the branch name shown in SonarQube is āmasterā. Should the SonarQube display the ādevelopā as the default branch name.
Yes ā this is an awful backward step. I have some apps on the Developer edition, and many on the Community Edition. So in upgrading from 6.7LTS to 7.x, we lose the ability to scan PRās.
Is this deliberate and intended to neuter the Community Edition?
Or are there settings I can make on the VSTS pipeline to allow PRās to start scanning once again?
@NicoB This has to be the dumbest āfeatureā I have ever seen a product introduce. Why on earth would you purposely cripple an otherwise decent product? You are literally forcing only the master branch, WHY??? I really would love to know how best to get this regression bug āfixedā so we can get the desired behavior back of allowing us to scan any branch back. Is this on the roadmap? what is the ETA? Thanks!
hi @NicoB ,
I am new to sonarQube and i came to know community edition latest version doesnot support sonar.branch.
I have sonar.xml provided by default in SAP hybris , which has sonar.branch property.
so i commented out
I want to analyse only 1 branch (not master). Is this possible with community edition ?