I'm having a hard time integrating DotCover reports from TeamCity into SonarQube. As far as I can see I'm doing everything correctly.
I really feel like I've missed something? I'm currently using TeamCity 2020.2 build 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 |
Code for step 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"
The unit test output shows in TeamCity but the report itself is not visible and shows no coverage in SonarQube. Eventhough in the build log report the following is presented:
[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]
Ironicly I found the answer today
This value needs to be added to the "Additional Parameters" field in the first step (Sonar Scanner for MsBuild: Begin analysis)
/d:sonar.cs.dotcover.reportsPaths="%system.teamcity.build.workingDir%\dotCover.html"