Skip to content

Commit

Permalink
Use recordCoverage in Jenkinsfiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Oct 17, 2023
1 parent a595710 commit 1703f83
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
39 changes: 29 additions & 10 deletions etc/Jenkinsfile.autograding
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ node {

stage ('Checkout') {
git branch:'master', url: 'https://github.com/uhafner/codingstyle.git', credentialsId: 'github-app'
}

stage ('Git mining') {
discoverGitReferenceBuild()
mineRepository()
}

stage ('Build and Static Analysis') {
stage ('Build, Test and Static Analysis') {
withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
sh 'mvn -ntp -V -e clean verify -Dmaven.test.failure.ignore -Dgpg.skip'
}
Expand All @@ -15,6 +19,7 @@ node {
recordIssues tool: errorProne(), healthy: 1, unhealthy: 20

junit testResults: '**/target/*-reports/TEST-*.xml'
recordCoverage tools: [[parser: 'JACOCO']], sourceCodeRetention: 'EVERY_BUILD'

recordIssues tools: [checkStyle(pattern: 'target/checkstyle-result.xml'),
spotBugs(pattern: 'target/spotbugsXml.xml'),
Expand All @@ -24,25 +29,39 @@ node {
qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]
}

stage ('Line and Branch Coverage') {
withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
sh "mvn -ntp -V -U -e jacoco:prepare-agent test jacoco:report -Dmaven.test.failure.ignore"
}
publishCoverage adapters: [jacocoAdapter('**/*/jacoco.xml')], sourceFileResolver: sourceFiles('STORE_ALL_BUILD')
}

stage ('Mutation Coverage') {
withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
sh "mvn -ntp org.pitest:pitest-maven:mutationCoverage"
}
step([$class: 'PitPublisher', mutationStatsFile: 'target/pit-reports/**/mutations.xml'])
recordCoverage tools: [[parser: 'PIT']], sourceCodeRetention: 'EVERY_BUILD'
}

stage ('Collect Maven Warnings') {
recordIssues tool: mavenConsole()
}

stage ('Autograding') {
autoGrade('{"analysis":{"maxScore":100,"weightError":-10,"weightHigh":-5,"weightNormal":-2,"weightLow":-1}, "tests":{"maxScore":100,"weightPassed":1,"weightFailures":-5,"weightSkipped":-1}, "coverage":{"maxScore":100,"weightCovered":1,"weightMissed":-1}, "pit":{"maxScore":100,"weightDetected":1,"weightUndetected":-1}}')
autoGrade('''
{
"analysis": {
"maxScore": 100,
"errorImpact": -5,
"highImpact": -2,
"normalImpact": -1,
"lowImpact": -1
},
"tests": {
"maxScore": 100,
"passedImpact": 0,
"failureImpact": -5,
"skippedImpact": -1
},
"coverage": {
"maxScore": 100,
"coveredPercentageImpact": 0,
"missedPercentageImpact": -1
}
}
''')
}
}
2 changes: 1 addition & 1 deletion etc/Jenkinsfile.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ node('java11-agent') {
recordIssues tool: errorProne(), healthy: 1, unhealthy: 20

junit testResults: '**/target/*-reports/TEST-*.xml'
publishCoverage adapters: [jacocoAdapter('**/*/jacoco.xml')], sourceFileResolver: sourceFiles('STORE_ALL_BUILD')
recordCoverage tools: [[parser: 'JACOCO']], sourceCodeRetention: 'EVERY_BUILD'

recordIssues tools: [checkStyle(pattern: 'target/checkstyle-result.xml'),
spotBugs(pattern: 'target/spotbugsXml.xml'),
Expand Down
2 changes: 1 addition & 1 deletion etc/Jenkinsfile.reference
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ node {
recordIssues tool: errorProne(), healthy: 1, unhealthy: 20

junit testResults: '**/target/*-reports/TEST-*.xml'
publishCoverage adapters: [jacocoAdapter('**/*/jacoco.xml')], sourceFileResolver: sourceFiles('STORE_ALL_BUILD')
recordCoverage tools: [[parser: 'JACOCO']], sourceCodeRetention: 'EVERY_BUILD'

recordIssues tools: [checkStyle(pattern: 'target/checkstyle-result.xml'),
spotBugs(pattern: 'target/spotbugsXml.xml'),
Expand Down

0 comments on commit 1703f83

Please sign in to comment.