Skip to content

Commit e875227

Browse files
author
Dónal Adams
committed
Add support for healthScaleFactor in JUnit Plugin.
1 parent 2676d6e commit e875227

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

job-dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext/archiveJunit.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ job('example-2') {
99
archiveJunit('**/minitest-reports/*.xml') {
1010
allowEmptyResults()
1111
retainLongStdout()
12+
healthScaleFactor()
1213
testDataPublishers {
1314
publishTestStabilityData()
1415
}

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/ArchiveJUnitContext.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class ArchiveJUnitContext extends AbstractContext {
99
final TestDataPublishersContext testDataPublishersContext
1010
boolean allowEmptyResults
1111
boolean retainLongStdout
12+
double healthScaleFactor = 1.0
1213

1314
ArchiveJUnitContext(JobManagement jobManagement) {
1415
super(jobManagement)
@@ -32,6 +33,16 @@ class ArchiveJUnitContext extends AbstractContext {
3233
retainLongStdout = retain
3334
}
3435

36+
/**
37+
* The amplification factor to apply to test failures when computing the test result contribution to the
38+
* build health score.
39+
* The default factor is {@code 1.0}.
40+
* @param factor
41+
*/
42+
void healthScaleFactor(double factor = 1.0) {
43+
healthScaleFactor = factor
44+
}
45+
3546
/**
3647
* Adds additional test report features provided by other Jenkins plugins.
3748
*/

job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class PublisherContext extends AbstractExtensibleContext {
134134
keepLongStdio(junitContext.retainLongStdout)
135135
testDataPublishers(junitContext.testDataPublishersContext.testDataPublishers)
136136
allowEmptyResults(junitContext.allowEmptyResults)
137+
healthScaleFactor(junitContext.healthScaleFactor)
137138
}
138139
}
139140

job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContextSpec.groovy

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ class PublisherContextSpec extends Specification {
345345
context.archiveJunit('include/*') {
346346
allowEmptyResults()
347347
retainLongStdout()
348+
healthScaleFactor()
348349
testDataPublishers {
349350
allowClaimingOfFailedTests()
350351
publishTestAttachments()
@@ -356,10 +357,11 @@ class PublisherContextSpec extends Specification {
356357
then:
357358
with(context.publisherNodes[0]) {
358359
name() == 'hudson.tasks.junit.JUnitResultArchiver'
359-
children().size() == 4
360+
children().size() == 5
360361
testResults[0].value() == 'include/*'
361362
allowEmptyResults[0].value() == true
362363
keepLongStdio[0].value() == true
364+
healthScaleFactor[0].value() == 1.0
363365
testDataPublishers[0].children().size() == 4
364366
testDataPublishers[0].'hudson.plugins.claim.ClaimTestDataPublisher'[0] != null
365367
testDataPublishers[0].'hudson.plugins.junitattachments.AttachmentPublisher'[0] != null
@@ -381,10 +383,11 @@ class PublisherContextSpec extends Specification {
381383
then:
382384
with(context.publisherNodes[0]) {
383385
name() == 'hudson.tasks.junit.JUnitResultArchiver'
384-
children().size() == 4
386+
children().size() == 5
385387
testResults[0].value() == 'include/*'
386388
keepLongStdio[0].value() == false
387389
allowEmptyResults[0].value() == false
390+
healthScaleFactor[0].value() == 1.0
388391
testDataPublishers[0].children().size() == 0
389392
}
390393
1 * jobManagement.requireMinimumPluginVersion('junit', '1.10')

0 commit comments

Comments
 (0)