如何使用声明性Jenkins文件设置pipelineTriggers?

时间:2017-10-13 15:37:23

标签: jenkins jenkins-pipeline

在脚本化的Jenkins文件中,您可以通过设置:

在“上游”项目上设置构建触发器
properties([
    pipelineTriggers([
        upstream(
            threshold: 'SUCCESS',
            upstreamProjects: 'UpstreamJob\master'
        )
    ])
])

如何在多分支管道作业中使用声明性Jenkins文件设置等效的pipelineTriggers?

如果我将pipelineTriggers放在'options'部分中,我会收到以下错误:

WorkflowScript: 20: Invalid option type "pipelineTriggers". Valid option types: [buildDiscarder, catchError, disableConcurrentBuilds, overrideIndexTriggers, retry, script, skipDefaultCheckout, skipStagesAfterUnstable, timeout, timestamps, waitUntil, withContext, withCredentials, withEnv, ws]

1 个答案:

答案 0 :(得分:2)

它不应该在'选项'中,而应在'触发器'部分。

尝试:

pipeline {
    triggers {
        upstream (
            threshold: 'SUCCESS',
            upstreamProjects: 'UpstreamJob\master'
        )
    }
}