Product
Solutions
Resources
Company
Download Trial Book a Demo

Publish Code Coverage to SonarQube

You will see how to publish code coverage to SonarQube in 2 simple steps. Enable the xml parameter in the RKTracer configuration file, set the reports path in the sonar properties file, then run the sonar scanner.

You will see how to publish code coverage to SonarQube in 2 simple steps:

  1. Enable the xml parameter in the RKTracer configuration file to generate the SonarQube xml file.
  2. 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.

generate the xml reports
rkresults -xml

With the above command, the RKTracer tool will generate two XML reports:

  • rktracer.xml for Jenkins
  • rktracer-sonarqube.xml for 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-project.properties
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.

In short

Run rkresults -xml to generate rktracer-sonarqube.xml, point sonar.coverageReportPaths at it in the sonar properties file, then run the sonar scanner.

Stuck on your build?

Open a support ticket and an engineer who knows your toolchain will help. You get a tracked ticket ID by email.