Jenkins声明式。触发另一个流水线并将阶段结果传递给当前流水线

问题描述 投票:0回答:1

我在Jenkins中有两个声明式的管道,我想在管道A内运行的阶段的参数内触发pipelineB,并检查pipelineB的构建阶段结果,以决定pipelineA是否应该继续或中止。我想在管道A内运行的阶段的参数内触发pipelineB,并检查pipelineB的buildstage结果,以决定pipelineA是否应该继续或中止。如果pipelineB的构建阶段结果是成功的,那么pipelineA应该继续阶段C,除非应该中止。

       stage('A'){
            steps{
                script{
                     //Do something
        }  


        stage ('B'){
            steps {
                script {
                        // Trigger another pipeline and check result of this
                        build job: 'pipelineB', parameters: [
                        string(name: 'param1', value: "value1")
                      ]
                }
            }
        }


        stage('C'){
            steps{
                script{
                   //Do something
        }
jenkins jenkins-pipeline jenkins-declarative-pipeline
1个回答
1
投票

获取下游作业构建结果并分配给上游作业构建结果。

script {
  // Trigger another pipeline and check result of this
  ret = build(job: 'pipelineB', 
                  parameters: [
                      string(name: 'param1', value: "value1")
                  ],
                  propagate: true,
                  wait: true)

  echo ret.result
  currentBuild.result = ret.result
}

读取 此处 详见

© www.soinside.com 2019 - 2024. All rights reserved.