Skip to content

Commit 1bd4cf3

Browse files
committed
JENKINS-287 Publish the Jacoco HTML report directly.
This saves roughly 1:30 minutes of build time. The Jacoco gradle plugin already creates HTML reports. So instead of using a Jenkins plugin to aggregate the results the existing results are published directly. This has some consequences: * improved build time * no overall coverage anymore, instead the coverage now depends on the test type * only full coverage for the most recent build and in contrast to the old version no coverage overview for older builds * there is still a coverage trend shown on the Plot section of the sidebar
1 parent 0a1a62f commit 1bd4cf3

File tree

2 files changed

+9
-192
lines changed

2 files changed

+9
-192
lines changed

Jenkinsfile

+9-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
#!groovy
22

3-
// place the cobertura xml files relative to the source, so that the source can be found
4-
def javaSrc = 'catroid/src/main/java'
5-
6-
def junitAndCoverage(String jacocoXmlFile, String coverageName, String javaSrcLocation) {
3+
def junitAndCoverage(String jacocoReportDir, String jacocoReportXml, String coverageName) {
74
// Consume all test xml files. Otherwise tests would be tracked multiple
85
// times if this function was called again.
96
String testPattern = '**/*TEST*.xml'
107
junit testResults: testPattern, allowEmptyResults: true
118
cleanWs patterns: [[pattern: testPattern, type: 'INCLUDE']]
129

13-
String coverageFile = "$javaSrcLocation/coverage_${coverageName}.xml"
14-
// Convert the JaCoCo coverate to the Cobertura XML file format.
15-
// This is done since the Jenkins JaCoCo plugin does not work well.
16-
// See also JENKINS-212 on jira.catrob.at
17-
sh "./buildScripts/cover2cover.py '$jacocoXmlFile' '$coverageFile'"
10+
publishJacocoHtml jacocoReportDir, jacocoReportXml, coverageName
1811
}
1912

20-
def postEmulator(String coverageNameAndLogcatPrefix, String javaSrcLocation) {
13+
def postEmulator(String coverageNameAndLogcatPrefix) {
2114
sh './gradlew stopEmulator clearAvdStore'
2215

23-
def jacocoXml = 'catroid/build/reports/coverage/catroid/debug/report.xml'
24-
junitAndCoverage jacocoXml, coverageNameAndLogcatPrefix, javaSrcLocation
16+
def jacocoReportDir = 'catroid/build/reports/coverage/catroid/debug'
17+
junitAndCoverage jacocoReportDir, 'report.xml', coverageNameAndLogcatPrefix
2518

2619
archiveArtifacts "${coverageNameAndLogcatPrefix}_logcat.txt"
2720
}
@@ -131,7 +124,7 @@ pipeline {
131124

132125
post {
133126
always {
134-
junitAndCoverage 'catroid/build/reports/jacoco/jacocoTestCatroidDebugUnitTestReport/jacocoTestCatroidDebugUnitTestReport.xml', 'unit', javaSrc
127+
junitAndCoverage 'catroid/build/reports/jacoco/jacocoTestCatroidDebugUnitTestReport', 'jacocoTestCatroidDebugUnitTestReport.xml', 'unit'
135128
}
136129
}
137130
}
@@ -145,7 +138,7 @@ pipeline {
145138

146139
post {
147140
always {
148-
postEmulator 'instrumented_unit', javaSrc
141+
postEmulator 'instrumented_unit'
149142
}
150143
}
151144
}
@@ -159,7 +152,7 @@ pipeline {
159152

160153
post {
161154
always {
162-
postEmulator 'pull_request_suite', javaSrc
155+
postEmulator 'pull_request_suite'
163156
}
164157
}
165158
}
@@ -177,7 +170,7 @@ pipeline {
177170

178171
post {
179172
always {
180-
postEmulator 'quarantined', javaSrc
173+
postEmulator 'quarantined'
181174
}
182175
}
183176
}
@@ -187,7 +180,6 @@ pipeline {
187180

188181
post {
189182
always {
190-
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: "$javaSrc/coverage*.xml", failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false, failNoReports: false
191183
step([$class: 'LogParserPublisher', failBuildOnError: true, projectRulePath: 'buildScripts/log_parser_rules', unstableOnWarning: true, useProjectRule: true])
192184
}
193185
changed {

buildScripts/cover2cover.py

-175
This file was deleted.

0 commit comments

Comments
 (0)