How to run one build at a time


I use CircleCI to build, once build is finished it updates a version file which triggers Concourse to start a pipeline. I want to only run the pipeline for one build at a time.

I have tried max_in_flight and serial_groups but neither quite do it for me. Here’s a drawing of my pipeline:


If I use the same serial_group for all my jobs, then the ones in “smaller groups” (i.e. blue boxes) will not run concurrently. I don’t want to stop concurrent executions, I just want that my pipeline’s first step doesn’t start until the pipeline finishes the previous run (successfully or with a fail).

The logic is “if the version has increased, don’t start the ‘trigger’ job unless all steps up to a failed one have finished after the last version change”.

What’s the best way to achieve this?


You can achieve this using the pool resource to acquire a lock on the trigger step then release it at finish or on a failure.