Hello Team,
I am using Community Edition Version 10.1 (build 73491) and am triggering the Sonar scan via Jenkins (via JenkinsFile). The command that I am using is (in JenkinsFile):
${DOTNET_SONARSCANNER_EXE_LOCATION} begin /k:"xxx" /s:"${localDirectory}\\SonarQube.Analysis.xml" /d:"sonar.verbose=true" /d:"sonar.cs.vscoveragexml.reportsPaths=.\\CoverageReports\\coverage.xml" /d:"sonar.nodejs.executable=${NODE_EXE_LOCATION}"
dotnet build ${localDirectory}\\xxx.sln --no-incremental
${DOTNET_CODECOVERAGE_EXE_LOCATION} collect "dotnet test ${localDirectory}\\xxxTests\\xxxTests.csproj" -f xml -o ".\\CoverageReports\\coverage.xml"
${DOTNET_SONARSCANNER_EXE_LOCATION} end
I referred the dotnet-coverage section of the following url : .NET test coverage
The scan happens successfully and in its report, it highlights other metrics, like Hotspot, vulnerabililities, and so on. However, the Code coverage always point to 0.0% (on new and overall code)
I already have an another CI (GoCI) and it show that 70% of the code is covered. However the same does not happen in Sonarqube. It just does not show the “Lines Covered” (in green color, I remember) and just shows 0.0%.
I am not sure what I am doing wrong. Request you to kindly assist me on the same. If your require anything please do let me know.
Hello Ann,
Thank you very much for your inputs.
The issue that i highlighted earlier, does not exists anymore.
However at the “end” step of SonarScanner, I am getting the below error:
Possible causes:
1. The project has not been built - the project must be built in between the begin and end steps 2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported. 3. The begin, build and end steps have not all been launched from the same folder 4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
The point # 1,2,3 are perfectly satisfied. Not sure about the last one.
My sln and underlying csproj targets .Net framework 4.8
I attach herewith the debug logs of the same.
Would be thankful to you if you can assist me with the missing piece of information.
Hello Ann,
The issue is sorted. I am able to see the code coverages now.
It was the issue with the sonar scanner that I was using.
I should have used SonarScanner.Msbuild, which was not the case and hence the issue.
Thank you for your help again. You can mark this ticket as Resolved.