Jenkins Declarative:触发另一个管道并将阶段结果传递给当前管道

Jenkins Declarative: Trigger another pipeline and pass the stage results to current pipeline

我在 Jenkins 中有两个声明式管道。我想在管道 A 内的 运行 阶段的参数内触发 pipelineB,并检查 pipelineB 的 build/stage 结果,以决定是继续还是中止 pipelineA。 如果 pipelineB build/stage 结果成功,则 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
        }

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

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
}

阅读here了解详情