tdh
tdh

Reputation: 123

SonarQube with new Branch feature fails with "a measure can be set only once for a specific Component"?

Trying out the newer branch support feature in SonarQube.

I have run into a bit of a problem which I do not understand.

I upgraded our SonarQube instance to the developer edition. Under the branch configuration for Long living branches pattern I set it to (develop|master) as we are using GitFlow branching strategy.

From a Jenkins job I executed the following after upgrading to the developer edition where I Pass the project key and name in. This works fine and I get an analysis for the website project shown.

C:\Jenkins\sitecore\develop>SonarScanner.MSBuild.exe" begin /d:sonar.login=******** /k:NEON /n:Website /v:Build#3-SHA#a37bc8060e8d5a4264140784b1f93c9a4ca80b43 /d:sonar.host.url=http://codeanalysis.remoteiv.dk /d:sonar.cs.nunit.reportsPaths=C:\Jenkins\sitecore\develop\NUnitResult.xml /d:sonar.cs.opencover.reportsPaths=C:\Jenkins\sitecore\develop\OpenCoverResult.xml

Then for subsequent runs Jenkins passes the feature branch name using the sonar.branch.name property as shown below.

C:\Jenkins\sitecore\feature-NEON-10-Setting-Up-Toll-Gate@2>SonarScanner.MSBuild.exe" begin /d:sonar.login=********** /k:NEON /n:Website /v:Build#5-SHA#2acea67103ab4b1223d80bf62d23999dd5369c29 /d:sonar.branch.name=feature-NEON-10-Setting-Up-Toll-Gate /d:sonar.host.url=http://codeanalysis.remoteiv.dk /d:sonar.cs.nunit.reportsPaths=C:\Jenkins\sitecore\feature-NEON-10-Setting-Up-Toll-Gate@2\NUnitResult.xml /d:sonar.cs.opencover.reportsPaths=C:\Jenkins\sitecore\feature-NEON-10-Setting-Up-Toll-Gate@2\OpenCoverResult.xml

The end step in Jenkins says it succeeds.

INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=30ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=341ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=1ms
INFO: Skipping CPD calculation for short living branch
INFO: Analysis report generated in 378ms, dir size=841 KB
INFO: Analysis reports compressed in 61ms, zip size=55 KB
INFO: Analysis report uploaded in 49ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://codeanalysis.remoteiv.dk/dashboard/index/NEON
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://codeanalysis.remoteiv.dk/api/ce/task?id=AWL3Sf5q5_IkahY6f6q6
INFO: Task total time: 1:02.311 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:04.661s
INFO: Final Memory: 23M/692M

But The analysis says it has failed on the server and there is no branch under the branches view on sonar server?

The error is.

{"task":{"id":"AWL3Sf5q5_IkahY6f6q6","type":"REPORT","componentId":"AWL3Mrk25_IkahY6f6qw","componentKey":"NEON","componentName":"Website","componentQualifier":"TRK","status":"FAILED","submittedAt":"2018-04-24T12:54:04+0200","submitterLogin":"jenkins","startedAt":"2018-04-24T12:54:05+0200","executedAt":"2018-04-24T12:54:15+0200","executionTimeMs":10155,"logs":false,"errorMessage":"a measure can be set only once for a specific Component (key=NEON:BRANCH:feature-NEON-10-Setting-Up-Toll-Gate), Metric (key=test_execution_time). Use update method (Visit failed for Component {key=NEON:BRANCH:feature-NEON-10-Setting-Up-Toll-Gate,type=PROJECT} )","hasScannerContext":true,"organization":"default-organization","branch":"feature-NEON-10-Setting-Up-Toll-Gate","branchType":"SHORT"}}

Any help would be appreciated.

Upvotes: 0

Views: 2154

Answers (1)

You are facing the following bug that will be fixed in the next version of SonarQube: SONAR-9384

A temporary workaround I found is the following:

  1. Go to your project "Administration > General Settings" page
  2. Search for the setting sonar.cs.vstest.reportsPaths
  3. Specify a dumb value, like foo

With this, the analyzer won't try to persist unit test information so this won't fail. The downside is that you will not have unit test measures - which IMO is perfectly acceptable compared to not having analyses at all.

Upvotes: 1

Related Questions