Jenkins parameterized job that only queues one build

后端 未结 7 811
暖寄归人
暖寄归人 2020-12-30 03:25

Imagine a Jenkins job A which takes 1 minute to run, and job B which takes 5 minutes.

If we configure job A to trigger job B, while job B is running job A may run 5

相关标签:
7条回答
  • 2020-12-30 04:20

    Ron's solution worked for me. If you don't like having bunch of cancelled builds in build history you can add the following system groovy script to job A before you trigger job B:

    import hudson.model.*  
    def q = jenkins.model.Jenkins.getInstance().getQueue()   
    def items = q.getItems()  
    for (i=0;i<items.length;i++){  
      if(items[i].task.getName() == "JobB"){  
        items[i].doCancelQueue()
      }   
    }
    
    0 讨论(0)
提交回复
热议问题