Reputation: 31
I have a maven Jenkins job (Jenkins version 2.105) with Jacoco and Sonar (Version 6.0) configured. The project has multiple jacoco.exec created and I need to put the path for the same under sonar.jacoco.reportpath. The code coverage comes up in sonar if I add for only one exec. While adding the others are comma separted values, code coverage in not displayed in Sonar.
As the version of SonarQube is prior to 6.2 I understand we are required to use sonar.jacoco.reportPath property and not sonar.jacoco.reportPaths. How do we configure multiple path here?
Upvotes: 3
Views: 2603
Reputation: 686
You need to merge your JaCoCo .exec files into a single binary file.
To achieve this use JaCoCo's merge mojo.
Cristian (from cristian.io) has an excellent walkthrough of how to achieve this here. The following is a slightly modified version of the code from that blog post.
def allTestCoverageFile = "$buildDir/jacoco/allTestCoverage.exec"
task jacocoMergeTest(type: JacocoMerge) {
destinationFile = file(allTestCoverageFile)
executionData = project.fileTree(dir: '.', include:'**/build/jacoco/test.exec')
}
sonarqube {
properties {
property "sonar.projectKey", "your.org:YourProject"
property "sonar.projectName", "YourProject"
property "sonar.jacoco.reportPath", allTestCoverageFile
}
}
Upvotes: 2