如何使用声明性 Jenkinsfile 设置管道触发器?

Ste*_*ess 4 jenkins jenkins-pipeline

在脚本化的 Jenkinsfile 中,您可以通过设置在“上游”项目上设置构建触发器:

properties([
    pipelineTriggers([
        upstream(
            threshold: 'SUCCESS',
            upstreamProjects: 'UpstreamJob\master'
        )
    ])
])
Run Code Online (Sandbox Code Playgroud)

如何在多分支管道作业中使用声明性 Jenkinsfile 设置等效的管道触发器?

如果我将 pipelineTriggers 放在“选项”部分,则会出现以下错误:

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

yor*_*mmi 5

It should not be in the 'options' but in the 'triggers' section.

Try:

pipeline {
    triggers {
        upstream (
            threshold: 'SUCCESS',
            upstreamProjects: 'UpstreamJob\master'
        )
    }
}
Run Code Online (Sandbox Code Playgroud)