Reputation: 463
I am writing a Jenkins DSL script (groovy) that will create a Jenkins Job. One of the options I would like the job to have enabled is the box that reads "Block build if certain jobs are running"
I tried to use the "blockOn" code that I found here: https://jenkinsci.github.io/job-dsl-plugin/#path/freeStyleJob-blockOn
But when I run my DSL script the job gets created and does NOT have the "Block build if certain jobs are running" box checked
Below is the entire DSL script that gets executed:
job('Testing-DSL') {
blockOn(['2.Dummy_job', '1 .Dummy_job']) {
blockLevel('GLOBAL')
scanQueueFor('ALL')
} //closing blockOn section
description('''\
This is just a template job that I use to reference how groovy code should look<br>
''')
logRotator(-1, 30, -1, -1)
parameters {
choiceParam('CHOICE1', ['choice_option1', 'option2'], 'Some description for this param')
stringParam('STRING1', 'Default_Value_string1', 'Some description for this option')
} //closing parameters section
steps {
shell('''\
echo $CHOICE1
echo $STRING1
''')
} //closing steps section
} //closing job section
Upvotes: 1
Views: 3695
Reputation: 8194
Your script is working for me, the "Block build if certain jobs are running" box is checked.
You may need to restart Jenkins before using Job DSL if you installed some plugins. See also https://github.com/jenkinsci/job-dsl-plugin/wiki/Frequently-Asked-Questions#why-isnt-my-generated-job-like-i-was-expecting-there-was-no-error-when-the-seed-job-ran.
Upvotes: 2