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:
- 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
- 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
- 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