Azure pipeline code coverage 0% in sonarqube maven spring boot project

Must-share information (formatted with Markdown):

  • SonarQube - SonarQube version: 7.9.1
  • Im trying to publish the Jacoco code coverage results from Azure pipeline to the SonarQube Server but coverage is always 0%.
  • what have you tried so far to achieve this
  1. Added a prepare analysis task on SonarQube
  2. Added the sonar scanner plugin (sonar-maven-plugin v 3.6.0.1398) and jacoco-maven-plugin v0.8.4 in the pom.xml.
  3. Done a clean build or package goal.
  4. Added publish quality gate results task
  5. Using the self hosted Agent.
  6. I could see the Jacoco coverage reports generated in Azure devops. but the coverage report is not getting published in SonarQube. Its always shows as 0%.

Kindly help me to resolve this issue and let me know if any further information is required

Hi,

Welcome to the community!

You might find this (near-concurrent) thread helpful:

 
HTH,
Ann

1 Like

Thanks Ann for the response.
Solution in the post you suggested says this “I got this working if I specify an explicit path in the build arguments in Azure DevOps”.

So, do i need to make changes in the maven clean build task’s Test results files field?

Basically, i wanted to understand, where i can set the build arguments?

Please advise

We’re using the “Maven pom.xml” task in Azure DevOps and you can specify it in the “Option” parameter like this…

-Dsonar.coverage.jacoco.xmlReportPaths=//jacoco.xml

1 Like

Thanks Ann and Devon.

Hi,

I am also facing the same issue, could you please share the maven task and how the parameters are passed into it ?

INFO: Skipping JaCoCo execution due to missing execution data file: /home/vsts/work/1/s/target/jacoco-report/jacoco.exec

but the jacoco.exec is residing at /jacoco/vsts/work/1/s/CCReport43F6D5EF/jaococe.exec

vinay

Please see my working settings below,

Maven task version 3

Options paramter has -Dsonar.coverage.jacoco.xmlReportPaths=$(System.DefaultWorkingDirectory)\CCReport43F6D5EF\jacoco.xml

Code coverage tool : Jacoco

Run SonarQube or SonarCloud analysis - Checked

Use latest release - Selected

thanks a lot, issue is resolved.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.