-
Bug
-
Resolution: Fixed
-
Minor
-
None
I would like to create a custom builder (using configure) in a Conditional Step.
job('example') { steps { conditionalSteps { condition { stringsMatch('${SOME_PARAMETER}', 'pants', false) } } } configure { project -> project / builders / 'org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder' / conditionalbuilders << 'hudson.tasks.Shell' { command 'echo Hello' } } }
The resulting config.xml becomes
<builders> <org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder> <runCondition class="org.jenkins_ci.plugins.run_condition.core.StringsMatchCondition"> <arg1>${SOME_PARAMETER}</arg1> <arg2>pants</arg2> <ignoreCase>false</ignoreCase> </runCondition> <runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/> <conditionalbuilders> <hudson.tasks.Shell> <command>echo Hello</command> </hudson.tasks.Shell> <hudson.tasks.Shell> <command>echo Hello</command> </hudson.tasks.Shell> <hudson.tasks.Shell> <command>echo Hello</command> </hudson.tasks.Shell> </conditionalbuilders> </org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder> </builders>
For some reason 2 superfluous commands are generated. If I change to:
project / builders / 'org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder' / conditionalbuilders / 'hudson.tasks.Shell' {
It works but only allow one step of each type. See discussion https://groups.google.com/forum/#!topic/job-dsl-plugin/MzUMLicGfH4 for more information.