将 TeamCity 的 DotCover 报告集成到 SonarQube 中?

Integrate DotCover reports from TeamCity into SonarQube?

我很难将来自 TeamCity 的 DotCover 报告集成到 SonarQube 中。据我所知,我做的一切都是正确的。

我真的觉得我错过了什么? 我目前正在使用 TeamCity 2020.2 内部版本 84587 SonarQube 8.5

Step Metarunner Content
1. Sonar Scanner for MsBuild: Begin analysis Project name: %system.teamcity.projectName%
2. Nuget Installer Pointer to sln
3. .Net Command: test
Projects:"Pointer to unit test csproj"
Configuration: Release
Output directory: %teamcity.build.checkoutDir%\Tests
Code coverage: Jetbrains dotCover
4. Powershell Look at code below
5. SonarScanner for MSBuild: finish analysis

第 4 步代码:

$snapshotfiles = Get-ChildItem "%system.teamcity.build.tempDir%\..\agentTmp" -recurse -Filter *.dcvr | select -ExpandProperty FullName
$snapshots = $snapshotfiles -join ";"
Write-Host $snapshots
%teamcity.dotCover.home%\dotCover.exe merge /Source=$snapshots /Output=%system.teamcity.build.checkoutDir%\dotcovermerge.dcvr
%teamcity.dotCover.home%\dotCover.exe report /ReportType=HTML /Source=%system.teamcity.build.checkoutDir%\dotcovermerge.dcvr /Output="%system.teamcity.build.checkoutDir%\dotCover.html"

单元测试输出显示在 TeamCity 中,但报告本身不可见,并且在 SonarQube 中未显示任何覆盖范围。 尽管在构建日志报告中显示了以下内容:

[12:57:41]  [Step 6/6] INFO: Sensor C# [csharp] (done) | time=820ms
[12:57:41]  [Step 6/6] INFO: Sensor C# Tests Coverage Report Import [csharp]
[12:57:41]  [Step 6/6] INFO: Aggregating the HTML reports from 'D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover.html'.
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover\src.html
[12:57:41]  [Step 6/6] INFO: Adding this code coverage report to the cache for later reuse: D:\TeamCityBuildAgent\workebc0abc7b8ceda0\dotCover.html
[12:57:41]  [Step 6/6] INFO: Coverage Report Statistics: 43 files, 34 main files, 34 main files with coverage, 9 test files, 0 project excluded files, 0 other language files.
[12:57:41]  [Step 6/6] INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=106ms
[12:57:41]  [Step 6/6] INFO: Sensor Sonargraph Integration [sonargraphintegration]

讽刺的是我今天找到了答案

第一步(Sonar Scanner for MsBuild:Begin analysis)需要在“Additional Parameters”字段中添加该值

/d:sonar.cs.dotcover.reportsPaths="%system.teamcity.build.workingDir%\dotCover.html"