VSTS的SonarQube代码覆盖率

Ant*_*nen 2 code-coverage sonarqube azure-devops

我正在使用VSTS托管代理VS2017来运行构建,测试和SonarQube分析。我正在使用来自市场(https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube)的SonarQube扩展。使用的任务版本是4,它将SonarQube Scanner用于MSBuild 4.0.2。

该分析效果很好,但是没有将代码覆盖率结果转换为SonarQube。我可以在VSTS(构建详细信息)中看到代码覆盖率分析,但在SonarQube中看不到。

以我的理解,问题在于VSTS生成扩展名为.codecoverage的二进制文件。SonarQube不知道如何处理此文件。我在将其转换为XML格式时遇到了麻烦,因为我似乎无能为力。

是否有人在SonarQube中成功使用了VSTS,并将代码覆盖率结果也带到了SonarQube?您如何设置?

编辑1
我使用的SonarQube版本是:6.7版(内部版本33306),社区版

编辑2
分析结束时实际上会生成xml文件,如下面的注释中所述。这来自日志:

2018-03-06T11:14:56.4189055Z 11:14:56.417  Attempting to locate the 
CodeCoverage.exe tool...
2018-03-06T11:14:56.4210147Z 11:14:56.42  Attempting to locate the 
CodeCoverage.exe tool using setup configuration...
2018-03-06T11:14:56.4345085Z 11:14:56.433  Code coverage command line tool: 
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team 
Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
2018-03-06T11:14:56.4349101Z 11:14:56.434  Fetching code coverage report 
information from TFS...
2018-03-06T11:14:56.4363869Z 11:14:56.435  Attempting to locate a test 
results (.trx) file...
2018-03-06T11:14:57.0458245Z 11:14:57.044  Looking for TRX files in: 
D:\a\1\TestResults, D:\a\1\s\TestResults
2018-03-06T11:14:57.0462747Z 11:14:57.045  Located a test results file: 
D:\a\1\s\TestResults\VssAdministrator_factoryvm-az436_2018-03-
06_11_13_09.trx
2018-03-06T11:14:57.0600587Z 11:14:57.059  One code coverage attachment was 
found in the trx file: factoryvm-az436\VssAdministrator_factoryvm-az436 
2018-03-06 11_11_34.coverage
2018-03-06T11:14:57.0602504Z 11:14:57.059  Absolute path to coverage file: 
D:\a\1\s\TestResults\VssAdministrator_factoryvm-az436_2018-03-
06_11_13_09\In\factoryvm-az436\VssAdministrator_factoryvm-az436 2018-03-06 
11_11_34.coverage
2018-03-06T11:14:57.0691948Z 11:14:57.068  Executing file C:\Program Files 
(x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynamic Code 
Coverage Tools\CodeCoverage.exe
2018-03-06T11:14:57.0692731Z   Args: analyze 
/output:D:\a\1\s\TestResults\VssAdministrator_factoryvm-az436_2018-03-
06_11_13_09\In\factoryvm-az436\VssAdministrator_factoryvm-az436 2018-03-06 
11_11_34.coveragexml D:\a\1\s\TestResults\VssAdministrator_factoryvm-
az436_2018-03-06_11_13_09\In\factoryvm-az436\VssAdministrator_factoryvm-
az436 2018-03-06 11_11_34.coverage 
2018-03-06T11:14:57.0694963Z   Working directory: 
D:\a\1\s\TestResults\VssAdministrator_factoryvm-az436_2018-03-
06_11_13_09\In\factoryvm-az436
2018-03-06T11:14:57.0695792Z   Timeout (ms):60000
2018-03-06T11:14:57.0699007Z   Process id: 3540
2018-03-06T11:14:58.7847582Z 11:14:58.783  Process returned exit code 0
2018-03-06T11:14:58.7858908Z 11:14:58.784  Updating project info files with 
code coverage information...
Run Code Online (Sandbox Code Playgroud)

Fab*_*eam 6

VSTS扩展名应自动导入coverage结果,但是目前存在一个回归(希望如此)将很快得到修复:SONARMSBRU-339

同时,VSTS扩展文档中的“分析.NET解决方案”中提供了一种解决方法:在Additional Properties文本区域中,添加以下属性:

sonar.cs.vscoveragexml.reportsPaths=**/*.coveragexml
Run Code Online (Sandbox Code Playgroud)