Coverage still 0% even if Sonar Scan read the jacoco report in Github Action

Hi,

I have a simple project with a front on Angular and a back with Java 11 (it’s an exercise). I have set up one gitHub action for the front and another one for the back. Each one runs the tests, generate coverage and launch the sonar scanner.

The logic is quite similar, it works well for the front but for the back i can’t manage to get my coverage on SonarCloud.

This is the command in the workflow :

 uses: sonarSource/sonarcloud-github-action@master
      with:
        args: -Dproject.settings=back/sonar-project.properties        
      env:
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACK }}

This is the sonar project properties :

sonar.projectKey=bdrorg_demarche-ci-cd-back
sonar.organization=bdrorg

sonar.sources=back/src/main
sonar.tests=back/src/test

sonar.java.binaries=back/target/classes
sonar.coverage.jacoco.xmlReportPaths=back/target/site/jacoco-aggregate/jacoco.xml

I know that the report is well seen by the scan thanks to this log :

INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=45ms

And i know that my jacoco xml report contains a coverage that is different from 0 (i already tried steps that shows what it contains).

This is my repo : GitHub - NoBdr07/Gerez-un-projet-collaboratif-en-int-grant-une-demarche-CI-CD

I already tried to destroy and create a new project in SonarCloud. I already tried solutions from similar problems in sonar community but nothing works. It’s been a few weeks of research that’s why I’m creating this new topic.

Thank you very much !

Hi @NoBdr07 ,

You can activate de debug mode to have more information about this problem. As the report file is read it could be the path file in jacoco.xml which the scanner can not associate.

Hi ! Thanks for your answer.

I already tried to activate the debug mode and the path was ok ! And if the scanner can not associate I have a warn that tell me so. So I’m quite sure that the scanner read it now, that’s why I don’t understand why the coverage is still 0 !

Hi @NoBdr07,

In back/pom.xml, You have 2 goals in jacoco-maven plugin-configuration : report and report-aggregate. Report-aggregate is used for “merging” multi module reports. In youre project it produce an empty xml file. You can remove this goal and modify this parameter in sonar-project.properties :

sonar.coverage.jacoco.xmlReportPaths=back/target/site/jacoco/jacoco.xml

1 Like

It works !

Thank you so much !

1 Like

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