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

Hi Team,

We are using Azure devops pipeline with sonar cloud integration and code coverage is showing in Azure Interface pipeline code coverage tab as shown in attachment but not showing in sonar cloud. Tasks sequence shown in screenshot below.

and using Ubuntu agent.

In prepare analysis for sonar cloud task, path is explicitly set where jacoco.xml is available,sonar.coverage.jacoco.xmlReportPaths=/home/vsts/work/1/s/development/CCReport43F6D5EF/jacoco.xml and same is set in maven/pom.xml options as
-Dsonar.coverage.jacoco.xmlReportPaths=/home/vsts/work/1/s/development/CCReport43F6D5EF/jacoco.xml

Can you point why the coverage is not coming in sonar cloud.

Hi @neha_malhotra and welcome to the community,

The options field in the Maven task is definitely not a good place to put any properties for the SonarCloud analysis.

Prepare analysis configuration can be, but make sure you don’t put any -D in front of the property, you can simply put “sonar.coverage.jacoco.xmlReportPaths=/home/vsts…” in the additional properties field.

Make sure also that you don’t set that property twice, so either choose the pom.xml of the additional property fields, it will help you troubleshoot in that specific case.

HTH,
Mickaël

Hi @mickaelcaro - no entry in options field i have set but still below paths gets set. Where does these setting from -

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

Also on sonar cloud dashboard gets warning —

Property ‘sonar.jacoco.reportPaths’ is no longer supported. Use JaCoCo’s xml report and sonar-jacoco plugin.

Though code coverage is showing in pipeline code coverage tab but not in sonar cloud

Ah yep i remember now, this property is set by the Maven extension itself, which contains logic to call the Sonar Scanner inside this same task.

Is it the wrong path on your side ?

Hi @mickaelcaro - Path is correct. But it is setting both -Dsonar.jacoco.reportPaths and -Dsonar.coverage.jacoco.xmlReportPaths and looks on sonar cloud its not able to read Dsonar.coverage.jacoco.xmlReportPaths

as warning is coming on sonarcloud interface
Property ‘sonar.jacoco.reportPaths’ is no longer supported. Use JaCoCo’s xml report and sonar-jacoco plugin.

Hi,

sonar.jacoco.reportPaths can be set for some cases where it should be still supported (older version of SQ and subsequent analyzers for instance).

The sonar.coverage.jacoco.xmlReportPaths is set automatically by the Maven task, so finally, you don’t need to set it up on your own as long as you are relying on default paths for the coverage xml file to be written.

Mickaël

Not setting sonar.jacoco.reportPaths but why sonarcloud is trying to use same.

We are not trying to use it, but as it is not supported anymore on our side, we are stil detecting it and display a warning that is shouldn’t be used anymore.

ok @mickaelcaro. So need to identify why sonar cloud is not able to read the jacoco.xml from azure though same works fine when its run from local set up.

Any specific logger we can put to check same?

Can you re-run the full build, with debug mode enabled on the pipeline, and send me the maven task log please ? I’ll have a look.

Thanks

Hi @mickaelcaro - Please find attachedlogs.txt (37.5 KB)

Hi @mickaelcaro - Were you able to check on same.

Hi @neha_malhotra

How did you set the debug mode ? Seems that it’s not enabled for the Scanner specifically.

Thanks

Had enabled checkbox to have diagnostics while running the pipeline

I don’t think it’s enough then. Could you please add the pipeline variable “system.debug” and set it to true please to see if it changes something ?

Thanks !

sure @mickaelcaro. Will check and update

Hi @mickaelcaro - Attached are debug logs from prepare analysis configurationsonar.txt (6.5 KB)

Thanks, this is not the right one, you sent me the Prepare analysis configuration task log, i need the maven one.

Hi @mickaelcaro - Please find attached logs8_Maven developmentpom.xml.txt (85.0 KB)

Hi @mickaelcaro - Were you able to check the same