How to add sonar.coverage.jacoco.xmlReportPaths in jenkins for android project ?
I was trying to configure jacoco plugin with sonarqube.
To do this, we need to provide sonarqube with the path of coverage report xml file generated by the jacoco plugin.
we can do this on local environment by adding a sonarqube property as shown below:
```
sonarqube {
properties {
property "sonar.projectKey", "APOS148"
property "sonar.projectName", "APOS148"
property "sonar.login", "sqp_380acb712c2121063b0e8b17e59644692ce3369b"
property "sonar.host.url", "http://localhost:9006"
property "sonar.projectVersion", "1.0"
property "sonar.sources", "src/main/java"
property "sonar.tests", "src/test/java"
property "sonar.coverage.jacoco.xmlReportPaths", "coverage/reports/TEST-1.NEW.xml" // Adjust the path as necessary
}
}
Place the file TEST-1.NEW.xml inside the app/coverage/reports directory of your android project or any other directory of your choice inside app directory.
If you are using jenkins to run sonarqube, then you need to add the path of jacoco coverage report xml file to the jenkins script.
To provide sonar.coverage.jacoco.xmlReportPaths in jenkins
we need to add the path of the file in the jenkins script as below:
```
-Dsonar.coverage.jacoco.xmlReportPaths=$workspace/<project name>coverage/reports/TEST-1.NEW.xml
replace <project-name> with your project’s root directory name.
$workspace gives the jenkins directory in which <project-name> is placed.
In this way we do not have to hard code the path of the jacoco coverage report file in jenkins script.
Happy coding :)
Subscribe to my newsletter
Read articles from mrtechmaker directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
mrtechmaker
mrtechmaker
Senior Android Developer. Skills: Android, Kotlin,Java,Postgresql,Linux.