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

3

我在将来自TeamCity的DotCover报告整合到SonarQube中遇到了困难。就我所看到的,我正在正确地进行一切。

我真的觉得我错过了什么?我目前使用的是 TeamCity 2020.2 build 84587 SonarQube 8.5

步骤 Metarunner 内容
1. Sonar Scanner for MsBuild: 开始分析 项目名称:%system.teamcity.projectName%
2. Nuget安装程序 指向sln
3. .Net 命令:test
项目:“指向单元测试csproj”
配置:Release
输出目录:%teamcity.build.checkoutDir%\Tests
代码覆盖率:Jetbrains dotCover
4. Powershell 查看下面的代码
5. SonarScanner for MSBuild: 完成分析

步骤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\work\4ebc0abc7b8ceda0\dotCover.html'.
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\1.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\10.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\11.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\12.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\13.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\14.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\15.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\16.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\17.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\18.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\19.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\2.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\20.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\21.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\22.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\23.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\24.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\25.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\26.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\27.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\28.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\29.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\3.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\30.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\31.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\32.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\33.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\34.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\35.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\36.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\37.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\38.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\39.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\4.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\40.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\41.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\42.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\43.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\44.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\5.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\6.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\7.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\8.html
[12:57:41]  [Step 6/6] INFO: Parsing the dotCover report D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\dotCover\src\9.html
[12:57:41]  [Step 6/6] INFO: Adding this code coverage report to the cache for later reuse: D:\TeamCityBuildAgent\work\4ebc0abc7b8ceda0\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]
1个回答

3
讽刺的是,我今天才找到答案。
这个值需要添加到第一步(Sonar Scanner for MsBuild: 开始分析)中的“附加参数”字段中。
/d:sonar.cs.dotcover.reportsPaths="%system.teamcity.build.workingDir%\dotCover.html"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接