How to limit Jenkins concurrent multibranch pipeline builds?

前端 未结 3 1300
猫巷女王i
猫巷女王i 2020-12-30 18:57

I am looking at limiting the number of concurrent builds to a specific number in Jenkins, leveraging the multibranch pipeline workflow but haven\'t found any good way to do

3条回答
  •  臣服心动
    2020-12-30 19:18

    Found what I was looking for. You can limit the concurrent builds using the following block in your Jenkinsfile.

    node {
      // This limits build concurrency to 1 per branch
      properties([disableConcurrentBuilds()])
    
      //do stuff
      ...
    }
    

    The same can be achieved with a declarative syntax:

    pipeline {
        options {
            disableConcurrentBuilds()
        }
    }
    

提交回复
热议问题