I want to display coverage on SonarQube

I want to display the coverage of java project on SonarQube.

I am using sonar-scanner.

However, the coverage is not reflected on SonarQube.

Please let me know if there is something missing in the execution content.

【Execution content】
①Run the following in a JDK 11 environment
mvn test jacoco:report
(Create “./target/site/jacoco/jacoco.xml”)

Next, in the JDK8 environment, the following was executed for the execution result of ①.

./node_modules/.bin/sonar-scanner
-Dsonar.host.url=http://xx.xx.xx.xx:9000/sonarqube
-Dsonar.projectBaseDir=./
-Dsonar.sources=./src
-Dsonar.exclusions=src/main/resources/**
-Dsonar.test=src/test
-Dsonar.sourceEncoding=UTF-8
-Dsonar.projectKey=xxxxxxxxx
-Dsonar.projectName=xxxxxxxxx
-Dsonar.dynamicAnalysis=false
-Dsonar.java.binaries=target/classes
-Dsonar.coverage.jacoco.xmlReportPaths=./target/site/jacoco/jacoco.xml

【version information】

SonarQube Community EditionVersion 7.3 (build 15553)

sonar-java-plugin-5.6.1.15064.jar

SonarQube Scanner 3.1.0.1141

Java 1.8.0_201 Oracle Corporation (64-bit)

Linux 5.10.16.3-microsoft-standard-WSL2 amd64

Hi,

First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.3 → 7.9.6 → 8.9.2 → 9.1 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

Regarding your actual question I believe you’ll need to do the upgrade for your JaCoCo XML report to be read properly.

Also since, you’re using Maven to build. You should use it to analyze as well. Then I believe including coverage should just work. And you’ll be able to eliminate many of the parameters you’re using.

And finally, once you upgrade you’ll find that you can run analysis with Java 11. In fact, you’ll have to.

 
HTH,
Ann

Hi,

Thank you.

Plan for version upgrade.

kenta

1 Like