diff --git a/job-dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext/archiveJunit.groovy b/job-dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext/archiveJunit.groovy index 69eacb64f..d71a9ede8 100644 --- a/job-dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext/archiveJunit.groovy +++ b/job-dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext/archiveJunit.groovy @@ -9,6 +9,7 @@ job('example-2') { archiveJunit('**/minitest-reports/*.xml') { allowEmptyResults() retainLongStdout() + healthScaleFactor() testDataPublishers { publishTestStabilityData() } diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/ArchiveJUnitContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/ArchiveJUnitContext.groovy index 219271b0e..5a583e337 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/ArchiveJUnitContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/ArchiveJUnitContext.groovy @@ -9,6 +9,7 @@ class ArchiveJUnitContext extends AbstractContext { final TestDataPublishersContext testDataPublishersContext boolean allowEmptyResults boolean retainLongStdout + double healthScaleFactor = 1.0 ArchiveJUnitContext(JobManagement jobManagement) { super(jobManagement) @@ -32,6 +33,16 @@ class ArchiveJUnitContext extends AbstractContext { retainLongStdout = retain } + /** + * The amplification factor to apply to test failures when computing the test result contribution to the + * build health score. + * The default factor is {@code 1.0}. + * @param factor + */ + void healthScaleFactor(double factor = 1.0) { + healthScaleFactor = factor + } + /** * Adds additional test report features provided by other Jenkins plugins. */ diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext.groovy index c2b475d02..41a977201 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContext.groovy @@ -134,6 +134,7 @@ class PublisherContext extends AbstractExtensibleContext { keepLongStdio(junitContext.retainLongStdout) testDataPublishers(junitContext.testDataPublishersContext.testDataPublishers) allowEmptyResults(junitContext.allowEmptyResults) + healthScaleFactor(junitContext.healthScaleFactor) } } diff --git a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContextSpec.groovy b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContextSpec.groovy index 9d1a33bfa..8ee010ddb 100644 --- a/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContextSpec.groovy +++ b/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/helpers/publisher/PublisherContextSpec.groovy @@ -345,6 +345,7 @@ class PublisherContextSpec extends Specification { context.archiveJunit('include/*') { allowEmptyResults() retainLongStdout() + healthScaleFactor() testDataPublishers { allowClaimingOfFailedTests() publishTestAttachments() @@ -356,10 +357,11 @@ class PublisherContextSpec extends Specification { then: with(context.publisherNodes[0]) { name() == 'hudson.tasks.junit.JUnitResultArchiver' - children().size() == 4 + children().size() == 5 testResults[0].value() == 'include/*' allowEmptyResults[0].value() == true keepLongStdio[0].value() == true + healthScaleFactor[0].value() == 1.0 testDataPublishers[0].children().size() == 4 testDataPublishers[0].'hudson.plugins.claim.ClaimTestDataPublisher'[0] != null testDataPublishers[0].'hudson.plugins.junitattachments.AttachmentPublisher'[0] != null @@ -381,10 +383,11 @@ class PublisherContextSpec extends Specification { then: with(context.publisherNodes[0]) { name() == 'hudson.tasks.junit.JUnitResultArchiver' - children().size() == 4 + children().size() == 5 testResults[0].value() == 'include/*' keepLongStdio[0].value() == false allowEmptyResults[0].value() == false + healthScaleFactor[0].value() == 1.0 testDataPublishers[0].children().size() == 0 } 1 * jobManagement.requireMinimumPluginVersion('junit', '1.10')