Issue: https://issues.jenkins-ci.org/browse/JENKINS-15570
In pom.xml, add the exclusion arguments as properties:
<coverage-exclusion-01>org/jooq/generated/**/*</coverage-exclusion-01>
<coverage-exclusion-02>**/Application.*</coverage-exclusion-02>
In Jenkinsfile add the following script to read the excluded properties. Eg: getMavenExclusionProps.groovy
def call(context) {
context.with {
def pom = readMavenPom file: ‘pom.xml’
props = readMavenPom().getProperties()
exclusionPattern = props.entrySet().findAll {entry -> entry.key.startsWith(‘coverage-exclusion-‘)}.collect{it.value}.join(‘,’)
return exclusionPattern
}
}
Pass the excluded properties variable when you call JaCoco test:
jacoco(execPattern: ‘**/target/jacoco.exec’, exclusionPattern: “${excludeProps}”)
Leave a Reply