Jenkins DSL 使用 Build Blocker Plugin 插件

Jenkins DSL using the Build Blocker Plugin plugin

我正在编写将创建 Jenkins 作业的 Jenkins DSL 脚本 (groovy)。我希望该作业启用的选项之一是显示 "Block build if certain jobs are running"

的框

我尝试使用我在此处找到的 "blockOn" 代码: https://jenkinsci.github.io/job-dsl-plugin/#path/freeStyleJob-blockOn

但是当我 运行 我的 DSL 脚本时,作业被创建并且没有选中 "Block build if certain jobs are running" 框

下面是执行的整个 DSL 脚本:

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

您的脚本对我有用,"Block build if certain jobs are running" 框已选中。

如果您安装了一些插件,您可能需要在使用 Job DSL 之前重新启动 Jenkins。另见 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