Jacco xml file not found in gitlab ci

Setup:
Java 11, maven, multi module project
Sonar v10.5 Developer edition

Project structure:
-Parent
-pom.xml
-.gitlab-ci.yml
-moduleA
-moduleB
-jacoco-coverage-aggregate

Problem:
sonar not picking up generated jacoco xml files in gitlab pipeline

mvn clean verify sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=jacoco-coverage-aggregate-report/target/site/jacoco-aggregate/jacoco.xml

gives

No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths=jacoco-coverage-aggregate-report/target/site/jacoco-aggregate/jacoco.xml

Debugging:

  1. Checked for file existence, using
test -e jacoco-coverage-aggregate-report/target/site/jacoco-aggregate/jacoco.xml || exit

and

cat jacoco-coverage-aggregate-report/target/site/jacoco-aggregate/jacoco.xml

Before invoking the command, the file is there

  1. Tried adding sonar.coverage.jacoco.xmlReportPaths property in the main pom file
    <sonar.coverage.jacoco.xmlReportPaths>
            ${basedir}/jacoco-coverage-aggregate-report/target/site/jacoco-aggregate/jacoco.xml
        </sonar.coverage.jacoco.xmlReportPaths>

Did not solve it

  1. Works when downloading the file, and running the command from my machine with full path to the file
mvn clean verify sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths=/Users/omar.salem/Downloads/jacoco1.xml

Related issue:
Sonarqube is unable to pickup code coverage report generated by Jacoco in my gitlab CI pipeline

Hi,

Where does the top-level jacoco-coverage-aggregate-report directory sit in your project structure? Could you maybe just generate the file straight into target?

 
Ann

Thanks for replying Ann.

the structure is for jacoco to work with multi modules, following this