Jacoco code coverage from Maven doesn't work anymore (azure devops)


We use Sonarqube * * Community Edition * Version 8.4.1 (build 35646)

In a maven build, we use jacoco to obtain the code coverage. The code coverage was going fine into Sonarqube until one day, we didn’t change anything.

Here are the setup :

Results jacoco report always present :

Then no more code coverage in sonarqube but jacaco report is present after the build :


Welcome to the community!

Have you looked at your job log to see what it says about your JaCoCo reports and how they’re read by analysis?


Hello, I have the jacoco reports well generated. Well they are perfectly generated and where they need to be.


Unfortunately sonarqube stoped to process them.


That isn’t what I asked (emphasis added).


Well I got the following at the end of the analysis (I replaced dnsname and proj key) :

[INFO] Analysis report generated in 133ms, dir size=2 MB

[INFO] Analysis report compressed in 486ms, zip size=918 KB

[INFO] Analysis report uploaded in 248ms

[INFO] ANALYSIS SUCCESSFUL, you can browse https://DNSNAME/dashboard?id=com.proj.key%3Asfcc

[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report

[INFO] More about the report processing at https://DNSNAME/api/ce/task?id=AXQKKHuM5M71q3obzkDQ

[INFO] Analysis total time: 28.994 s

Again today.

In sonarqube:

In the build:

Are you generating binary (EXEC) format files or XML files? The newer versions of the JaCoCo plugin do not analyze the binary format.

Look in the log of your Sonarqube scan for messages about whether or not it found the JaCoCO file and analyzed it. Is your file being created in the location specified in the sonar.coverage.jacoco.xmlReportPaths property? Is it the property set as part of your scan properties? Is there a default value in Administration->JaCoCo?

We use XML files. Also we didn’t change any config or parameters since the time it was working.

/usr/share/apache-maven-3.6.3/bin/mvn -f /home/vsts/work/1/s/pom.xml -Ddocker.tag.name=1.4.4800 clean verify -Dsonar.jacoco.reportPaths=/home/vsts/work/1/s/CCReport43F6D5EF/jacoco.exec -Dsonar.coverage.jacoco.xmlReportPaths=/home/vsts/work/1/s/CCReport43F6D5EF/jacoco.xml org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar

As we can see, we do have the properties.
In Administration->JaCoCo there aren’t path configured.

You’re specifying both sonar.jacoco.reportPaths and sonar.coverage.jacoco.xmlReportPaths. Is it possible this is throwing Sonar off?

Have you checked the log from the scan to ensure it’s finding the JaCoCo file and analyzing it?

Apparently it doesn’t throw Sonar off, as it only look at what it expect, thus one of them is ignored.

Regarding the log multiple time I get :

Then at the end :

On sonar :

Hi @Xoib,

To troubleshoot further will require logs of the analysis running in debug mode, as stated in your previous screenshot. You can activate debug logging by adding the property sonar.verbose=true to the Advanced area of your Prepare Analysis task within your pipeline. Please post the logs resulting from the next pipeline run after doing this.

Thanks. Attached is the log : sonar_build_log.zip (495.6 KB)

To remind you the setup is :

Ah, my apologies, my suggested mechanism for enabling debug logging won’t affect running maven within a later pipeline step. You’ll need to enable debugging within the maven task. Can you add the debug (-X) parameter to the maven command in that task? And then please supply the log.

Here is the log with debug (-X) : sonar_log_debug.zip (2.0 MB)
Same password.

Thank you.

Thank you. Can you also supply the coverage file that was used by this analysis? /home/vsts/work/1/s/CCReport43F6D5EF/jacoco.xml

One thing I noticed which seems odd: you are passing the coverage report in to the maven command from outside, via -Dsonar.coverage.jacoco.xmlReportPaths=/home/vsts/work/1/s/CCReport43F6D5EF/jacoco.xml

Whereas you’re running JaCoCo within the build again, apparently only generating .exec format files, and then not recreating an aggregate XML file. Somewhere in here, I suspect, lies your issue.

Sure, here it is : Code Coverage Report_5755_2.zip (861.3 KB)

Well here is the config, nothing fancy :


Is there anything under Advanced passing additional parameters to maven?

I see this in your log, and there are a number of related parameters un-accounted for in your screenshots:

2020-09-09T19:55:37.4592008Z [command]/usr/share/apache-maven-3.6.3/bin/mvn -f /home/vsts/work/1/s/pom.xml -Ddocker.tag.name=1.4.5755 -X clean verify -Dsonar.jacoco.reportPaths=/home/vsts/work/1/s/CCReport43F6D5EF/jacoco.exec -Dsonar.coverage.jacoco.xmlReportPaths=/home/vsts/work/1/s/CCReport43F6D5EF/jacoco.xml org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar

The parameter -Dsonar.jacoco.reportPaths should no longer be passed as it was deprecated and ultimately removed. And I remain curious why -Dsonar.coverage.jacoco.xmlReportPaths=/home/vsts/work/1/s/CCReport43F6D5EF/jacoco.xml is being passed in from outside; the JaCoCo XML report should really be generated within this build.

Nothing within Advanced paramters.

I don’t have control over what is passed from the Maven Task (it is Azure DevOps native task for Maven).

I know about the deprecated stuff but note that one day this config already worked. Plus we are getting the Jacoco code coverage. Just not in SonarQube.