Code Coverage not showing in Sonar Cloud though coming in Code Coverage Tab under Azure Devops Pipeline

Hi @neha_malhotra

There are no more information on this one, we will do without, that’s fine.

I got another idea while reviewing the config of the maven task : can you check that the “Use XML Jacoco reports for SonarQube analysis” configuration is ticket on the maven task ? It should appear once you’ve selected JaCoCo as coverage tool and enabled SQ analysis.

Let me know.

Thanks !

Hi ,

Its enabled.

Can you please show me again the option field of you maven task config please ? Are you setting any extra sonar properties in it ?

Hi @mickaelcaro - Please find attached.sonar.zip (111.0 KB)

Also have already tried below option -
removing prepare for analysis task and unchecking sonar analysis checkbox in mvn task and explicitly setting sonar parameters including cloud url etc in Maven Options the way we run in local, this does not show warning of xmlReportPaths attribute on sonar cloud but coverage is 0 on sonar cloud though from local using same mechanism it works. Basically “Run SonarQube or SonarCloud analysis” in maven task is adding deprecated sonar.jacoco.reportPaths.

Hi @mickaelcaro - Kindly update on same

Hi @mickaelcaro - Were you able to check on same

Hi @neha_malhotra

Sorry, just back from holidays.

I was finally able to test a very simple project on my side, and coverage is ok on SonarCloud, so i’m guessing this is probably something with your configuration.

The fact that the exec jacoco coverage file is being passed to our processing engine is not a big deal, we simply ignore it with a warning on the dashboard.

Do you have a multi-module maven project ? Or is it a “simple” one ?

@mickaelcaro Its multimodule project

@mickaelcaro If you can share your configuration for multi module maven project where coverage is shown on sonar cloud ,will check once our settings as per that.

I tested only on single module project. Can you check this documentation and specifically the multi module build part, and see if something is missing on your side ?

Thanks !

1 Like

Hi @mickaelcaro - Have checked the post and have similar structure in the project. To mention, running the sonar from local on the project and connecting to sonar cloud from local generates coverage on sonar cloud but similar using maven task in azure pipeline following same parameters not doing. Also can you please check this post

Which looks exact issue and says that it worked using command line task. Can you check this one what exactly was done to fix.

Hi @neha_malhotra

Do you have some kind of jacoco plugin inside your pom’s, or you rely on the one that is executed by the maven task ?

If yes, my guess would be to simply select “None” in the Code coverage dropdown instead of JaCoCo. Please be sure with that to setup manually or in your pom’s the relevant sonar.jacoco report path properties.

hi @mickaelcaro - Managed to get coverage on sonar by doing below changes -
removing prepare analysis configuration task
updating Maven task to not include any sonar run settings and just do clean install
publishing code coverage to Azure (code coverage publishes in pipeline tab) so that aggregated jacoco.xml file is there
then again including maven task that only does sonar:sonar with all properties to push changes to sonar cloud using parameters
-Dsonar.projectKey=
-Dsonar.organization=
-Dsonar.host.url=
-Dsonar.login=-Dsonar.coverage.jacoco.xmlReportPaths=/home/vsts/work/1/s/development/CCReport43F6D5EF/jacoco.xml

This gave coverage on sonar cloud, though coverage % on sonar cloud vs azure pipeline dashboard has lot difference though both using same jacoco.xml file. Any idea on same if you have.

Hi @neha_malhotra

Please follow my latest instruction, ie in the Maven task, select None as code coverage. With that, the maven task will run the jacoco plugin according to the setting you’ve put in your different poms, including the path to the aggregated coverage xml file.

Usually discrepencies appear as we don’t have the same computation as azure : whole files might not be analyzed, there can be some dependencies linked not analyzed as well, this can lead to coverage percentage not being the same.

hi @mickaelcaro - Have updated few sonar exclusions that were missing earlier after that it worked.

Thanks for all your support

1 Like

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