【问题标题】:Jenkins DSL using the Build Blocker Plugin pluginJenkins DSL 使用 Build Blocker Plugin 插件
【发布时间】:2018-08-23 09:16:52
【问题描述】:

我正在编写一个 Jenkins DSL 脚本(groovy),它将创建一个 Jenkins 作业。我希望该作业启用的选项之一是显示“如果某些作业正在运行则阻止构建”的框

我尝试使用在这里找到的“blockOn”代码: https://jenkinsci.github.io/job-dsl-plugin/#path/freeStyleJob-blockOn

但是当我运行我的 DSL 脚本时,作业被创建并且没有选中“如果某些作业正在运行,则块构建”框

下面是被执行的整个 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

【问题讨论】:

    标签: jenkins jenkins-job-dsl


    【解决方案1】:

    您的脚本正在为我工​​作,“如果某些作业正在运行,则阻止构建”框已选中。

    如果您安装了一些插件,您可能需要在使用 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

    【讨论】:

    • 好尴尬。好决定。重新启动 Jenkins(我刚刚安装了插件,没有重新启动)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多