SonarQube 7.2, VSTS Plugin 4.3.0 stop work with Pull request

Must-share information:

  • SonarQube 7.2, VSTS Plugin 4.3.0
  • Work with pull request
    04:22:07.775 ERROR: Caused by: Validation of project reactor failed:
    o To use the property “sonar.pullrequest.key”, the branch plugin is required but not installed. See the documentation of branch support: https://redirect.sonarsource.com/doc/branches.html.
    o To use the property “sonar.pullrequest.branch”, the branch plugin is required but not installed. See the documentation of branch support:
    o To use the property “sonar.pullrequest.base”, the branch plugin is required but not installed. See the documentation of branch support:

Hi Nikita,

Pull Request support requires at least the developer edition of SonarQube. If you don’t want to analyze your pull requests and keep using the community edition, then simply create a second build definition without any SonarQube task, and use it in your branch strategy to build pull requests.

Does it make sense?

It’s not a good thing!
I have equal definition for all processes
And see QG for all OR.
Why now it is illegal case

How was it working before SonarQube 7.2 ? If you don’t pass any parameter and let SonarQube analyze your pull requests, it will erase the analysis of the main branch. Were you using any other special configuration or custom plugin to analyze your pull requests without erasing master analysis?

I update SQ to 7.2 and use VSTS Plugin 4.3.0
It happened after update to VSTS Plugin 4.3.0

It happened because sonar-scanner-vsts pass values automatically :frowning:

async function populateBranchAndPrProps(props: { [key: string]: string }) {
  const collectionUrl = tl.getVariable('System.TeamFoundationCollectionUri');
  const prId = tl.getVariable('System.PullRequest.PullRequestId');
  const provider = tl.getVariable('Build.Repository.Provider');
  if (prId) {
    props['sonar.pullrequest.key'] = prId;
    props['sonar.pullrequest.base'] = branchName(tl.getVariable('System.PullRequest.TargetBranch'));
    props['sonar.pullrequest.branch'] = branchName(
      tl.getVariable('System.PullRequest.SourceBranch')

I’m still seeing this in version 4.3.1 of the plugin.

Hi @rycornell

Can you please provide the debug logs of the prepare task?

Thanks

2018-07-06T10:30:16.4623460Z ##[section]Starting: Prepare analysis on SonarQube
2018-07-06T10:30:16.5547110Z ==============================================================================
2018-07-06T10:30:16.5592050Z Task         : Prepare Analysis Configuration
2018-07-06T10:30:16.5636340Z Description  : Prepare SonarQube analysis configuration
2018-07-06T10:30:16.5679780Z Version      : 4.3.1
2018-07-06T10:30:16.5723290Z Author       : sonarsource
2018-07-06T10:30:16.5779120Z Help         : [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2018-07-06T10:30:16.5835720Z ==============================================================================
2018-07-06T10:30:17.6661960Z SYSTEMVSSCONNECTION exists true
2018-07-06T10:30:17.9899740Z [command]/usr/bin/dotnet /agents/agent1/_work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/4.3.1/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll begin /k:TestProject
2018-07-06T10:30:17.9962730Z SonarScanner for MSBuild 4.3.1
2018-07-06T10:30:18.0005480Z Using the .NET Core version of the Scanner for MSBuild
2018-07-06T10:30:18.1900970Z Default properties file was found at /agents/agent1/_work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/4.3.1/dotnet-sonar-scanner-msbuild/SonarQube.Analysis.xml
2018-07-06T10:30:18.1982570Z Loading analysis properties from /agents/agent1/_work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/4.3.1/dotnet-sonar-scanner-msbuild/SonarQube.Analysis.xml
2018-07-06T10:30:18.2057520Z Pre-processing started.
2018-07-06T10:30:18.2115540Z Preparing working directories...
2018-07-06T10:30:18.3868190Z 10:30:18.384  Updating build integration targets...
2018-07-06T10:30:18.3888550Z 10:30:18.387  Installed SonarQube.Integration.ImportBefore.targets to /root/.local/share/Microsoft/MSBuild/4.0/Microsoft.Common.targets/ImportBefore
2018-07-06T10:30:18.3908310Z 10:30:18.387  Installed SonarQube.Integration.ImportBefore.targets to /root/.local/share/Microsoft/MSBuild/10.0/Microsoft.Common.targets/ImportBefore
2018-07-06T10:30:18.3928760Z 10:30:18.388  Installed SonarQube.Integration.ImportBefore.targets to /root/.local/share/Microsoft/MSBuild/11.0/Microsoft.Common.targets/ImportBefore
2018-07-06T10:30:18.3947960Z 10:30:18.388  Installed SonarQube.Integration.ImportBefore.targets to /root/.local/share/Microsoft/MSBuild/12.0/Microsoft.Common.targets/ImportBefore
2018-07-06T10:30:18.3967630Z 10:30:18.388  Installed SonarQube.Integration.ImportBefore.targets to /root/.local/share/Microsoft/MSBuild/14.0/Microsoft.Common.targets/ImportBefore
2018-07-06T10:30:18.3987200Z 10:30:18.388  Installed SonarQube.Integration.ImportBefore.targets to /root/.local/share/Microsoft/MSBuild/15.0/Microsoft.Common.targets/ImportBefore
2018-07-06T10:30:18.4006670Z 10:30:18.388  Installed SonarQube.Integration.ImportBefore.targets to /root/Microsoft/MSBuild/15.0/Microsoft.Common.targets/ImportBefore
2018-07-06T10:30:18.4032010Z 10:30:18.389  Installed SonarQube.Integration.targets to /agents/agent1/_work/2/.sonarqube/bin/targets
2018-07-06T10:30:18.4056190Z 10:30:18.391  Creating config and output folders...
2018-07-06T10:30:18.4079040Z 10:30:18.391  Creating directory: /agents/agent1/_work/2/.sonarqube/conf
2018-07-06T10:30:18.4107650Z 10:30:18.391  Creating directory: /agents/agent1/_work/2/.sonarqube/out
2018-07-06T10:30:18.4131570Z 10:30:18.404  Fetching analysis configuration settings...
2018-07-06T10:30:18.4149580Z 10:30:18.408  Downloading from http://sonarqube:9000/api/server/version...
2018-07-06T10:30:18.5234730Z 10:30:18.521  Fetching properties for project 'TestProject' from http://sonarqube:9000/api/settings/values?component=TestProject...
2018-07-06T10:30:18.5262320Z 10:30:18.522  Downloading from http://sonarqube:9000/api/settings/values?component=TestProject...
2018-07-06T10:30:18.5860460Z 10:30:18.584  Downloading from http://sonarqube:9000/api/languages/list...
2018-07-06T10:30:18.6001200Z 10:30:18.598  Fetching quality profile for project 'TestProject' from http://sonarqube:9000/api/qualityprofiles/search?projectKey=TestProject...
2018-07-06T10:30:18.6028250Z 10:30:18.599  Downloading from http://sonarqube:9000/api/qualityprofiles/search?projectKey=TestProject...
2018-07-06T10:30:18.6734020Z 10:30:18.671  Fetching active rules for quality profile 'cs-sonar-way-53525' from http://sonarqube:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile=cs-sonar-way-53525&p=1...
2018-07-06T10:30:18.6770740Z 10:30:18.671  Downloading from http://sonarqube:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile=cs-sonar-way-53525&p=1...
2018-07-06T10:30:18.7931640Z 10:30:18.79  Fetching rules not active in quality profile 'cs-sonar-way-53525' for language 'cs' from http://sonarqube:9000/api/rules/search?f=internalKey&ps=500&activation=false&qprofile=cs-sonar-way-53525&p=1&languages=cs...
2018-07-06T10:30:18.7966500Z 10:30:18.791  Downloading from http://sonarqube:9000/api/rules/search?f=internalKey&ps=500&activation=false&qprofile=cs-sonar-way-53525&p=1&languages=cs...
2018-07-06T10:30:18.8875170Z 10:30:18.883  Local analyzer cache: /agents/agent1/_work/_temp/.sonarqube/resources
2018-07-06T10:30:18.9151190Z 10:30:18.91  Writing Roslyn generated ruleset to /agents/agent1/_work/2/.sonarqube/conf/SonarQubeRoslyn-cs.ruleset...
2018-07-06T10:30:18.9870570Z 10:30:18.982  Writing Roslyn analyzer additional file to /agents/agent1/_work/2/.sonarqube/conf/cs/SonarLint.xml...
2018-07-06T10:30:18.9945580Z 10:30:18.991  Provisioning analyzer assemblies for cs...
2018-07-06T10:30:18.9989220Z 10:30:18.994  Installing required Roslyn analyzers...
2018-07-06T10:30:19.0032800Z 10:30:18.996  Processing plugin: csharp version 7.2.0.5463
2018-07-06T10:30:19.2965780Z 10:30:19.293  Cache miss: plugin files were not found in the local cache
2018-07-06T10:30:19.3026900Z 10:30:19.296  Fetching resource for plugin: csharp, version 7.2.0.5463. Resource: SonarAnalyzer-7.2.0.5463.zip
2018-07-06T10:30:19.3107370Z 10:30:19.298  Downloading SonarAnalyzer-7.2.0.5463.zip from http://sonarqube:9000/static/csharp/SonarAnalyzer-7.2.0.5463.zip to /agents/agent1/_work/_temp/.sonarqube/resources/0
2018-07-06T10:30:19.3191910Z 10:30:19.3  Downloading file from http://sonarqube:9000/static/csharp/SonarAnalyzer-7.2.0.5463.zip to /agents/agent1/_work/_temp/.sonarqube/resources/0/SonarAnalyzer-7.2.0.5463.zip...
2018-07-06T10:30:19.3348060Z 10:30:19.33  Extracting files to /agents/agent1/_work/_temp/.sonarqube/resources/0...
2018-07-06T10:30:19.4589440Z 10:30:19.455  Pre-processing succeeded.
2018-07-06T10:30:19.5039820Z ##[section]Finishing: Prepare analysis on SonarQube

I’ve attached the exact error below. It is slightly different that the error described in the post topic, but I believe I saw another community post that linked to this one. Also, we’ve since downgraded to SonarQube 7.1 and we do not receive the error.

2018-07-06T10:30:39.4725230Z ##[error]10:30:39.461 ERROR: Error during SonarQube Scanner execution
2018-07-06T10:30:39.4761590Z 10:30:39.461 ERROR: Error during SonarQube Scanner execution
2018-07-06T10:30:39.4923090Z ##[error]10:30:39.461 ERROR: Unable to load component class org.sonar.scanner.scan.ProjectLock
10:30:39.461 ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.DefaultInputModuleHierarchy
10:30:39.461 ERROR: Caused by: Validation of project reactor failed:
  o To use the property "sonar.branch.name", the branch plugin is required but not installed. See the documentation of branch support: https://redirect.sonarsource.com/doc/branches.html.
2018-07-06T10:30:39.4984940Z 10:30:39.461 ERROR: Unable to load component class org.sonar.scanner.scan.ProjectLock
2018-07-06T10:30:39.5020950Z 10:30:39.461 ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.DefaultInputModuleHierarchy
2018-07-06T10:30:39.5057220Z 10:30:39.461 ERROR: Caused by: Validation of project reactor failed:
2018-07-06T10:30:39.5094090Z   o To use the property "sonar.branch.name", the branch plugin is required but not installed. See the documentation of branch support: https://redirect.sonarsource.com/doc/branches.html.

Sorry if I was not clear. Cloud you please enable VSTS debug logs (setting the variable system.debug to true when you queue your build). I’m interested to have the value of all build variables we are relying on to compute configuration (like Build.SourceBranch).

Thanks

2018-07-11T09:54:44.0647510Z ##[debug]extraProperties=# Additional properties that will be passed to the scanner, 
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
sonar.verbose=true
sonar.sources=TestProject
sonar.cs.opencover.reportsPaths=**/*opencover.xml
2018-07-11T09:54:44.0674890Z ##[debug]set SONARQUBE_SCANNER_MODE=MSBuild
2018-07-11T09:54:44.0734700Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MODE;issecret=false;]MSBuild
2018-07-11T09:54:44.0758810Z ##[debug]set SONARQUBE_ENDPOINT=********
2018-07-11T09:54:44.0796030Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_ENDPOINT;issecret=true;]********
2018-07-11T09:54:44.0822870Z ##[debug]set SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"http://sonarqube:9000/","sonar.login":********,"sonar.projectKey":"TestProject","sonar.projectName":"Test Project","sonar.projectVersion":"1.0","sonar.verbose":"true","sonar.sources":"TestProject","sonar.cs.opencover.reportsPaths":"**/*opencover.xml"}
2018-07-11T09:54:44.0864840Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS;issecret=false;]{"sonar.host.url":"http://sonarqube:9000/","sonar.login":********,"sonar.projectKey":"TestProject","sonar.projectName":"Test Project","sonar.projectVersion":"1.0","sonar.verbose":"true","sonar.sources":"TestProject","sonar.cs.opencover.reportsPaths":"**/*opencover.xml"}

Are you sure you give the correct build log? I can’t see any mention of sonar.branch.name being passed to the scanner.

Yes, that’s the problem. We do not set sonar.branch.name, but the error message indicates that we do.

Hi. was there a resolution to this? I’ve recently upgraded to 7.2 and am also receiving the same error as the previous user. We are using the community edition and not passing sonar.branch.name explicitly.

I see @smccollough created the new thread below, more specifically on the behaviour of VSTS extension 4.3.2:

Let’s follow-up there as this topic here started on VSTS extension 4.3.0, and VSTS-161 has been released in the meantime.

Same problem in version 4.3.2 after update SQ to 7.2.1. How to solve it? Problem is not in TFVC but in TFGIT repository. We want to analyze only one branch without pull request. Before update it works fine after update build failed. What is solution?
Edit: Prepare analysis is 4.3.2 and Run analysis is 4.3.0.

OK, my question could be … How to setup analyze to another branch than master? On master branch analyse works fine but we need setup analyze to developer branch (only one branch). Thanks.

It is very nice support. How it seem in payed version …?

Is there any chance to work with previous version? Our backup admin setup full dayly backup so backup from upgrade is not available. Need help because version 7.2.1 is not usable.

Hi Petr,

There have been two kinds of error messages mentioned in this thread:

(pull-request related)

And:

(branch related)

Which one are you encountering here ? If latter then as discussed it might worth following-up in this newer thread I mentioned. Specifically in light of your latest notes:

We want to analyze only one branch without pull request

How to setup analyze to another branch than master?

Below note might be insightful:

Which in turns means you cannot perform an analysis on another branch than master (with Git on VSTS ; related code fwiw).