You will see how to publish code coverage to SonarQube in 2 simple steps:
- Enable the
xmlparameter in the RKTracer configuration file to generate the SonarQube xml file. - Set the reports path in the sonar properties file to the SonarQube xml file in the project.
Step 1: Enable the xml parameter
Enable the xml parameter in the RKTracer configuration file to generate the SonarQube xml file. When you generate RKTracer code coverage reports, you need to use the following parameter along with the report generate command.
rkresults -xml
With the above command, the RKTracer tool will generate two XML reports:
rktracer.xmlfor Jenkinsrktracer-sonarqube.xmlfor SonarQube
Step 2: Set the reports path in the sonar properties file
Set the reports path in the sonar properties file to the SonarQube xml file in the project. To publish code coverage to SonarQube, you need to edit the project properties file and add the following details.
sonar.exclusions=rktracer/** sonar.language=java sonar.java.binaries=target/classes sonar.coverageReportPaths=/home/user/project-path/rktracer/report/rktracer-sonarqube.xml
Then run the sonar scanner to publish the code coverage data to SonarQube.
Run rkresults -xml to generate rktracer-sonarqube.xml, point sonar.coverageReportPaths at it in the sonar properties file, then run the sonar scanner.