Skip to content

Commit 1703f83

Browse files
committed
Use recordCoverage in Jenkinsfiles.
1 parent a595710 commit 1703f83

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

etc/Jenkinsfile.autograding

+29-10
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ node {
33

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

8+
stage ('Git mining') {
9+
discoverGitReferenceBuild()
10+
mineRepository()
711
}
812

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

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

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

27-
stage ('Line and Branch Coverage') {
28-
withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
29-
sh "mvn -ntp -V -U -e jacoco:prepare-agent test jacoco:report -Dmaven.test.failure.ignore"
30-
}
31-
publishCoverage adapters: [jacocoAdapter('**/*/jacoco.xml')], sourceFileResolver: sourceFiles('STORE_ALL_BUILD')
32-
}
33-
3432
stage ('Mutation Coverage') {
3533
withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
3634
sh "mvn -ntp org.pitest:pitest-maven:mutationCoverage"
3735
}
38-
step([$class: 'PitPublisher', mutationStatsFile: 'target/pit-reports/**/mutations.xml'])
36+
recordCoverage tools: [[parser: 'PIT']], sourceCodeRetention: 'EVERY_BUILD'
3937
}
4038

4139
stage ('Collect Maven Warnings') {
4240
recordIssues tool: mavenConsole()
4341
}
4442

4543
stage ('Autograding') {
46-
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}}')
44+
autoGrade('''
45+
{
46+
"analysis": {
47+
"maxScore": 100,
48+
"errorImpact": -5,
49+
"highImpact": -2,
50+
"normalImpact": -1,
51+
"lowImpact": -1
52+
},
53+
"tests": {
54+
"maxScore": 100,
55+
"passedImpact": 0,
56+
"failureImpact": -5,
57+
"skippedImpact": -1
58+
},
59+
"coverage": {
60+
"maxScore": 100,
61+
"coveredPercentageImpact": 0,
62+
"missedPercentageImpact": -1
63+
}
64+
}
65+
''')
4766
}
4867
}

etc/Jenkinsfile.coverage

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ node('java11-agent') {
1717
recordIssues tool: errorProne(), healthy: 1, unhealthy: 20
1818

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

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

etc/Jenkinsfile.reference

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ node {
1919
recordIssues tool: errorProne(), healthy: 1, unhealthy: 20
2020

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

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

0 commit comments

Comments
 (0)