Which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)?
- SonarQube Developer Edition v8.9.1 build 44547
- SonarQube DevOps extension version 5.0.0
What are you trying to achieve?
I am trying to get unit test and code coverage results published from our Azure DevOps build pipeline into SonarQube.
What have you tried so far to achieve this?
We are using Azure DevOps multi-staged pipelines defined in yaml. Relevant snippet of my pipeline yaml below:
- job: sonarqube displayName: Sonarqube Security Scan steps: - task: SonarQubePrepare@4 inputs: SonarQube: SonarQube scannerMode: 'MSBuild' projectKey: [REDACTED] extraProperites: | sonar.cs.opencover.reportsPaths=$(Agent.BuildDirectory)/**/coverage.opencover.xml - bash: dotnet build displayName: Debug build for security scan - bash: make test displayName: Unit tests - task: SonarQubeAnalyze@4 - task: SonarQubePublish@4 inputs: pollingTimeoutSec: 300
make test command runs the unit tests and generates the coverage report using coverlet using the following script. It generates a
coverage.opencover.xml in the UnitTests directory.
#!/bin/bash set -e dotnet test ./test/UnitTests/UnitTests.csproj -p:CollectCoverage=true -p:CoverletOutputFormat=opencover echo "Generating coverage report if you want to view it locally." dotnet tool update -g dotnet-reportgenerator-globaltool reportgenerator -reports:test/**/coverage.*.xml -targetdir:coveragereport
I have validated that the coverage.opencover.xml is being created in Azure DevOps, but for some reason I am still getting no test information in SonarQube.
Any help is very much appreciated!