I’m trying to generate a code coverage report from a Maven, Scala project.
It’s a multi-module project and I use scoverage-maven-plugin v1.4.11 to generate the aggregated coverage reports. The project is built in Java8.
I have the prepare step setup in devops as
- task: SonarQubePrepare@5
I build the project, then switch the environment to Java11 for SonarQube to work.
To generate the report I use
- task: Maven@3 with goals: ‘scoverage:report-only’
Then to run the analysis I use
- task: Maven@3 with sonarQubeRunAnalysis: true
When I investigate the SonarQube Analysis logs I see
[INFO] Sensor Scoverage sensor for Scala coverage [sonarscala]
[INFO] Importing /workspace/9/s/xx/target/cobertura.xml
[INFO] Sensor Scoverage sensor for Scala coverage [sonarscala] (done) | time=406ms
Which leads me to believe the coverage file has been found and uploaded
Finally I run SonarQubePublish@5
However the dashboard reflects 0% coverage.
If I publish the coverage file to Devops it correctly reflects the actual coverage.
How do I get my coverage correctly reflected in SonarQube?
Can you share a screenshot of what you do see in SonarQube?
It’s definitely strange that there are no other warnings/errors in the log – I would suggest two things:
- Outside of Azure DevOps reporting coverage, have you verified that /workspace/9/s/xx/target/cobertura.xml contains coverage information (it’s not, for example, reporting 0s for all fies?)
- Can you upload a snippet of your coverage file?
cobertura.txt (4.3 KB)
I’ve attached a snippet of the cobertura.xml file
Thanks for providing all this information.
With the different tasks of the pipeline taking place in a different context, are the file paths matching from one task to the other?
I am asking because this has happened in the past with coverage information built using absolute paths that cannot be matched from one task to the other
I’m pretty sure they are. I’ve taken the following bits from the logs
PublishCoverageResults (to devops)
The “xx” are just the project folders and are identical.
FWIW I’ve attached the main pom file.
pom.txt (2.9 KB)