concurrency on a trigger, step, or block to control competing runs that share its key and scope. Choose cancel-intermediate to replace work that has barely started while letting an older run finish:
- The oldest run started less than 15 seconds ago.
- Less than 30 seconds have passed since the first run in that replacement chain started.
value: 2, a quick burst behaves like this:
If B arrives when A is already 15 seconds old, A stays instead. After either deadline, the policy keeps the oldest run and the newest runs that fit the configured retention window, cancelling intermediate runs. With
value: 2 and no queue_size, that means the oldest and newest. Cancelled work still holds its slot until it stops.
Once a step with cancellable: false starts (built-in deploy and terraform:apply by default), neither cancelling behavior cancels that pipeline run. This protection does not detect publishing or infrastructure changes inside arbitrary shell commands; mark such steps cancellable: false yourself.
The replacement windows are part of cancel-intermediate; you do not need another setting. Other behaviors stay separate:
queuewaits for a slot without cancelling older runs.skipskips new work when the limit is reached.cancel-in-progresscancels older work without the age limits above. Both cancelling behaviors respectcancellable: false(below).value: 0allows unlimited concurrency and does not apply these cancellations.
Shared holders
By default every holder of a key isexclusive: it takes one of the value slots. Set mode: shared on a step’s concurrency to let it run alongside any number of other shared holders of the same key while still never running alongside an exclusive one. A shared run queues while an exclusive run holds the key, and an exclusive run queues until every shared holder has finished. Waiters are promoted in arrival order, so a queued exclusive run is never overtaken by shared runs that arrive after it. Steps and blocks of one run that hold the same key at the same time must use the same mode.
With value: 1 this is a reader/writer lock. Terraform plans only read state, so plans from different branches can run at the same time, while an apply needs the stack to itself:
Steps that must not be cancelled
Setcancellable: false on a step’s or block’s concurrency to keep a run holding the key there from being cancelled by a newer run under cancel-in-progress or cancel-intermediate. The newer run queues behind it instead, and a cancellation that arrives after the step has started is refused. Manual cancellation still works. Built-in deploy and terraform:apply steps default to cancellable: false; every other step defaults to true.
Use this when steps that share a key are not equally safe to interrupt. The excerpt below shows only the concurrency fields; see step types for the rest of each step. A newer run’s plan cancels an older run’s plan on the same stack, but waits for an apply: