具有新分支功能的SonarQube失败,“一个度量只能为特定组件设置一次”?

时间:2018-04-24 12:05:31

标签: sonarqube sonarqube-scan

在SonarQube中试用新的分支支持功能。

我遇到了一些我不明白的问题。

我将SonarQube实例升级为开发人员版。在Long living branches模式的分支配置下,我将其设置为(develop | master),因为我们正在使用GitFlow分支策略。

在Jenkins的工作中,我升级到开发人员版本后执行了以下操作,我将项目密钥和名称输入。这样工作正常,我对所显示的网站项目进行了分析。

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

然后对于后续运行,Jenkins使用sonar.branch.name属性传递功能分支名称,如下所示。

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

詹金斯的最后一步说它成功了。

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

但分析说它在服务器上失败了,声纳服务器上的分支视图下没有分支?

错误是。

{"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"}}

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

您正面临以下错误,该错误将在下一版SonarQube中修复:SONAR-9384

我找到的临时解决方法如下:

  1. 转到您的项目"管理>一般设置"页
  2. 搜索设置sonar.cs.vstest.reportsPaths
  3. 指定一个哑值,例如foo
  4. 有了这个,分析仪不会试图保留单元测试信息,所以这不会失败。缺点是你不会有单位测试的措施 - 与完全没有分析相比,IMO是完全可以接受的。