In some cases you may want to prevent a repository from running multiple builds at the same time, or you may even want to prevent certain branches or events from executing at the same time.
You can set concurrency limits (below) to limit the number of named pipelines that can execute at the same time. You will see we name the pipeline “deploy” and we limit concurrency to “1”. This will instruct Drone to only execute 1 pipeline named “deploy” at a time.
kind: pipeline
name: deploy
concurrency:
limit: 1
steps: ...
In some cases you may want to limit concurrency based on event or branch. We can do this by defining multiple pipelines in our yaml. In the below example, the first pipeline that we define limits tag events to a single concurrent build. The second pipeline will execute push and pull_request events with no concurrency limits (unbounded).
---
kind: pipeline
name: tag
concurrency:
limit: 1
steps: ...
trigger:
event: [ tag ]
---
kind: pipeline
name: default
steps: ...
trigger:
event: [ pull_request, push ]
Please note the internal scheduler makes a reasonable effort to enforce pipeline concurrency, however, the system does not make formal guarantees. If you require formal guarantees you should consider integrating a locking system into your pipeline (such as redislock or zookeeper).