Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved documentation and added argument validation for Multijob Plugin #1050

Merged
merged 1 commit into from
Aug 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.Preconditions

class MultiJobStepContext extends StepContext {
private static final List<String> VALID_CONTINUATION_CONDITIONS = [
'SUCCESSFUL', 'UNSTABLE', 'COMPLETED', 'FAILURE', 'ALWAYS'
]

MultiJobStepContext(JobManagement jobManagement, Item item) {
super(jobManagement, item)
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import javaposse.jobdsl.dsl.Preconditions

class PhaseContext extends AbstractContext {
private static final List<String> VALID_EXECUTION_TYPES = ['PARALLEL', 'SEQUENTIALLY']
private static final List<String> VALID_CONTINUATION_CONDITIONS = [
'SUCCESSFUL', 'UNSTABLE', 'COMPLETED', 'FAILURE', 'ALWAYS'
]

protected final Item item

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down