Trying to exclude packages from coverage report as my Jenkins pipeline fail. I have a sub project with all POJO:s. I don't want to write uittest for all these. Hence, they will drag down branch/line coverage som that coverage will be below threshold and fail my build.
It should be possible to exclude some packages, but I cant get it to work.
I have the following jacoco.gradle file:
apply plugin: 'jacoco'
apply plugin: 'java'
jacoco {
toolVersion = "0.8.2"
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled true
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: '**xxx/yyy/zzz/**')
})
}
task coverage { dependsOn 'jacocoTestReport' }
check.dependsOn 'jacocoTestReport'
The following in my sonar.gradle file:
apply plugin: 'org.sonarqube'
sonarqube {
properties {
property "sonar.forceAnalysis", "true"
property "sonar.forceAuthentication", "true"
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.login", ""
property "sonar.password", ""
}
}
subprojects {
sonarqube {
properties {
property "sonar.jacoco.reportPaths",
"$buildDir/reports/jacoco/allTests.exec"
property "sonar.junit.reportsPath", "$buildDir/test-results/test"
}
}
}
task sonar { dependsOn 'sonarqube' }
In my build.gradle:
apply from: 'gradle/sonar.gradle'
...
apply plugin: 'java'
...
subprojects {
apply from: '../gradle/jacoco.gradle'
...
}
And finally from my Jenkins file:
step([$class: 'JacocoPublisher', changeBuildStatus: false,
exclusionPattern: '**/*Test*.class', inclusionPattern:
'**/*.class', minimumBranchCoverage: '80', sourcePattern: '**/src'])
try {
dir(BUILD_DIR) {
sh './gradlew sonar'
}
But still the xxx.yyy.zzz Is generated in the coverage report in Jenkins!