Jacoco coverage not working
Hi,
I have been trying to get sonar code coverage working, with no luck so far. It used to work, so it's more like I'm trying to fix something, but it has been a long time, since it got broken...
The thing is... if I run my build locally, then everything is fine... gradle jacoco plugin generates code coverage exec files at each module level and an aggregated report in the root directory. At the end of such an execution I can see code coverage on sonar dashboard page. However, if I run the same command in TeamCity, then I can see jacoco exec files present in each module build directory, but there is no $rootDir/build/jacoco directory after a successful build, and code coverage shows as 0%.
The command I use is:
$ gradle clean test sonarRunner
Gradle configuration:
jacoco {
toolVersion = "0.7.9"
reportsDir = file("$buildDir/jacoco/reports")
}
test {
jacoco {
append true
destinationFile file("$rootDir/build/jacoco/test.exec")
reports {
html {
enabled true
destination "$buildDir/jacoco/test"
}
}
}
maxParallelForks = 4
}
And top level configuration:
apply plugin: 'org.sonarqube'
sonarqube {
properties {
property "sonar.junit.reportsPath", "$buildDir/test-results"
property "sonar.jacoco.reportPath", "$rootDir/build/jacoco/test.exec"
property "sonar.jacoco.itReportPath", "$rootDir/build/jacoco/acceptanceTest.exec"
property "sonar.jacoco.excludes", "*/st/*"
property "sonar.projectKey", projectKey
property "sonar.projectName", description
property "sonar.projectDescription", description
property "sonar.projectVersion", version
property "sonar.host.url", "${project.sonarUrl}"
property "sonar.login", "${project.sonarLogin}"
property "sonar.password", "${project.sonarPassword}"
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.groovy.coveragePlugin", "jacoco"
property "sonar.exclusions", [
"**/org/apache/**",
"**/org/springframework/**",
"**/static/**",
"**/public/vendor/**",
"**/public/js/**",
"**/main/groovy/**/testutils/**"
]
}
}
task sonarRunner(dependsOn: 'sonarqube')
Thanks,
Marcin
Please sign in to leave a comment.
Ok, I thought it was TeamCity invoking the process somehow differently, but it turned out I was running a slightly different version of Gradle on my agents.
This issue has been solved.
Thanks,
Marcin