diff --git a/docs/Home.md b/docs/Home.md index 863bcfb65..a32f4ab70 100755 --- a/docs/Home.md +++ b/docs/Home.md @@ -29,6 +29,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins ## Release Notes * 1.65 (unreleased) + * Enhanced support for the [Multijob Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin) + ([#1050](https://github.com/jenkinsci/job-dsl-plugin/pull/1050)) * 1.64 (July 07 2017) * Increased the minimum supported Java version to JDK 7 * Increased the minimum supported Jenkins version to 2.19 diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/MultiJobStepContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/MultiJobStepContext.groovy index e2e1e6a36..72c4d8d39 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/MultiJobStepContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/MultiJobStepContext.groovy @@ -7,10 +7,6 @@ import javaposse.jobdsl.dsl.JobManagement import javaposse.jobdsl.dsl.Preconditions class MultiJobStepContext extends StepContext { - private static final List VALID_CONTINUATION_CONDITIONS = [ - 'SUCCESSFUL', 'UNSTABLE', 'COMPLETED', 'FAILURE', 'ALWAYS' - ] - MultiJobStepContext(JobManagement jobManagement, Item item) { super(jobManagement, item) } @@ -32,19 +28,14 @@ class MultiJobStepContext extends StepContext { /** * Adds a MultiJob phase. * - * {@code continuationCondition} must be one of {@code 'SUCCESSFUL'}, {@code 'UNSTABLE'}, {@code 'COMPLETED'} or - * {@code 'FAILURE'}. When version 1.16 or later of the MultiJob plugin is installed, {@code continuationCondition} - * can also be set to {@code 'ALWAYS'}. + * {@code continuationCondition} must be one of {@code 'SUCCESSFUL'}, {@code 'UNSTABLE'}, {@code 'COMPLETED'}, + * {@code 'FAILURE'} or {@code 'ALWAYS'}. */ void phase(String name, String continuationCondition, @DslContext(PhaseContext) Closure phaseClosure) { PhaseContext phaseContext = new PhaseContext(jobManagement, item, name, continuationCondition) ContextHelper.executeInContext(phaseClosure, phaseContext) Preconditions.checkNotNullOrEmpty(phaseContext.phaseName, 'A phase needs a name') - Preconditions.checkArgument( - VALID_CONTINUATION_CONDITIONS.contains(phaseContext.continuationCondition), - "Continuation Condition needs to be one of these values: ${VALID_CONTINUATION_CONDITIONS.join(', ')}" - ) stepNodes << new NodeBuilder().'com.tikal.jenkins.plugins.multijob.MultiJobBuilder' { phaseName phaseContext.phaseName diff --git a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/PhaseContext.groovy b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/PhaseContext.groovy index 4fce1e507..3c685214e 100644 --- a/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/PhaseContext.groovy +++ b/job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/PhaseContext.groovy @@ -9,6 +9,9 @@ import javaposse.jobdsl.dsl.Preconditions class PhaseContext extends AbstractContext { private static final List VALID_EXECUTION_TYPES = ['PARALLEL', 'SEQUENTIALLY'] + private static final List VALID_CONTINUATION_CONDITIONS = [ + 'SUCCESSFUL', 'UNSTABLE', 'COMPLETED', 'FAILURE', 'ALWAYS' + ] protected final Item item @@ -22,7 +25,7 @@ class PhaseContext extends AbstractContext { super(jobManagement) this.item = item this.phaseName = phaseName - this.continuationCondition = continuationCondition + this.continuationCondition(continuationCondition) this.executionType = executionType } @@ -35,8 +38,15 @@ class PhaseContext extends AbstractContext { /** * Defines how to decide the status of the whole MultiJob phase. + * + * {@code continuationCondition} must be one of {@code 'SUCCESSFUL'}, {@code 'UNSTABLE'}, {@code 'COMPLETED'}, + * {@code 'FAILURE'} or {@code 'ALWAYS'}. */ void continuationCondition(String continuationCondition) { + Preconditions.checkArgument( + VALID_CONTINUATION_CONDITIONS.contains(continuationCondition), + "Continuation Condition needs to be one of these values: ${VALID_CONTINUATION_CONDITIONS.join(', ')}" + ) this.continuationCondition = continuationCondition }