Added executionType parameter to have an ability to run phase jobs SE…#929
Conversation
…QUENTIALLY or PARALLEL
| */ | ||
| void phase(String name, String continuationCondition, @DslContext(PhaseContext) Closure phaseClosure) { | ||
| PhaseContext phaseContext = new PhaseContext(jobManagement, item, name, continuationCondition) | ||
| void phase( |
There was a problem hiding this comment.
This will break compatibility as it changes a signature. Leave the signature as it is, just adding a new method to PhaseContext is sufficient.
| PhaseContext(JobManagement jobManagement, Item item, String phaseName, String continuationCondition) { | ||
| PhaseContext( | ||
| JobManagement jobManagement, Item item, String phaseName, String continuationCondition, | ||
| String executionType |
There was a problem hiding this comment.
Don't add another constructor parameter here. Set the field to the default value.
| } | ||
|
|
||
| /** | ||
| * Defines how to run the whole MultiJob phase. |
There was a problem hiding this comment.
Add a @since tag which points to the next version.
| VALID_CONTINUATION_CONDITIONS.contains(phaseContext.continuationCondition), | ||
| "Continuation Condition needs to be one of these values: ${VALID_CONTINUATION_CONDITIONS.join(', ')}" | ||
| ) | ||
| Preconditions.checkArgument( |
There was a problem hiding this comment.
Move this check to the executionType method in PhaseContext.
|
|
||
| /** | ||
| * Defines how to run the whole MultiJob phase. | ||
| */ |
There was a problem hiding this comment.
This feature need version 1.22 of the MultiJob plugin. Add a @RequiresPlugin annotation.
|
Suggested fixes has been applied |
daspilker
left a comment
There was a problem hiding this comment.
This is going in the right direction, there are a few things that I forgot to mention last time.
| stepNodes << new NodeBuilder().'com.tikal.jenkins.plugins.multijob.MultiJobBuilder' { | ||
| phaseName phaseContext.phaseName | ||
| delegate.continuationCondition(phaseContext.continuationCondition) | ||
| delegate.executionType(phaseContext.executionType) |
There was a problem hiding this comment.
This needs to be wrapped in an if block testing jobManagement.isMinimumPluginVersionInstalled(...) so that the new element only gets generated if the minimum required plugin version is installed.
| thrown(DslScriptException) | ||
|
|
||
| where: | ||
| execution << ['FOO'] |
There was a problem hiding this comment.
do not use a where section if there is only one option
| } | ||
|
|
||
| where: | ||
| execution << ['SEQUENTIALLY'] |
There was a problem hiding this comment.
do not use a where section if there is only one option, but you could also test both supported options here
There was a problem hiding this comment.
I think this is a good option to modify codenarcTest to catch such conditions
|
Suggested fixes has been applied |
I've added an ability to switch between execution types in multi jobs step plugin.
This options was missed in job dsl plugin.
Basically it can switch between sequential or parallel execution type of jobs within the phase.