成功完成另一个作业后,如何使作业运行自动化?

时间:2019-06-03 07:14:39

标签: jenkins multibranch-pipeline

假设我有两个多分支管道詹金斯作业ABC和XYZ,现在我想在ABC作业成功完成的同时自动开始XYZ作业。我该怎么办?

1 个答案:

答案 0 :(得分:0)

如果您使用的是詹金斯管道

node(){
  ..
  .. 
  ..
  if (currentBuild.result == "SUCCESS") {
    // If wait is set to true you can use the downstream_build.result to define the 
    //currentBuild.result
    def downstream_build = build job: '<path-to>/another-build-job', wait: true
    // Here you can set dependency between downstream and current build job
    currentBuild.result = downstream_build.result
  }
}

如果您将wait设置为false,则管道可以立即完成,但不能使用下游_build.result

node(){
  ..
  .. 
  ..
  if (currentBuild.result == "SUCCESS") {
    def downstream_build = build job: '<path-to>/another-build-job', wait: false
  }
}

另一种方法是Trigger Plugin

相关问题