After we upgraded our SonarQube to Version 7.9.2 (build 30863), Community Edition
, running the GitLab CI Pipeline results in showing 0.0%
coverage (dropping from about 86.2%
), although Sonar is showing all unit tests.
Maven build executed in .gitlab-ci.yml
looks like this:
- mvn test sonar:sonar -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONAR_TOKEN}
Obviosuly this has something to deal with notorious sonar.coverage.jacoco.xmlReportPaths
and sonar.jacoco.reportPaths
Sonar-JaCoCo plugin settings (see https://docs.sonarqube.org/pages/viewpage.action?pageId=1442166).
After looking into the pipeline jobs logs, I found the following (project name obfuscated to myProject
):
Before SonarQube upgrade:
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
[INFO] Sensor SurefireSensor [java]
[INFO] parsing [/builds/myProject/target/surefire-reports]
[INFO] Sensor SurefireSensor [java] (done) | time=87ms
[INFO] Sensor JaCoCoSensor [java]
[WARNING] Property 'sonar.jacoco.reportPaths' is deprecated (JaCoCo binary format). 'sonar.coverage.jacoco.xmlReportPaths' should be used instead (JaCoCo XML format). Please check that the JaCoCo plugin is installed on your SonarQube Instance.
[INFO] Analysing /builds/myProject/target/jacoco.exec
[INFO] Sensor JaCoCoSensor [java] (done) | time=206ms
After SonarQube upgrade:
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
[INFO] Sensor SurefireSensor [java]
[INFO] parsing [/builds/myProject/target/surefire-reports]
[INFO] Sensor SurefireSensor [java] (done) | time=86ms
[INFO] Sensor JavaXmlSensor [java]
[INFO] 1 source files to be analyzed
[INFO] Sensor JavaXmlSensor [java] (done) | time=302ms
Therefore the are obviously some differences in regards to sonar.jacoco.reportPaths
setting.
Notably, I don't explicitly set any of the two settings.
How to fix parsing of the JaCoCo report so that it works (regardless with old or new setting)?