Limit pipeline concurrency with pipeline-level lock
Problem to solve
Prevent pipeline collisions/race conditions in scenarios when multiple merges land in a close timeframe. Currently, it's possible that earlier pipelines can finish later than more recent pipelines because jobs in the earlier pipeline are queued so newer jobs go first. In this case, older code can be the last to be deployed. This forces teams to keep track of running pipelines (at least on the master branch) and wait to merge their code until it's clear.
Proposal
Pipeline-level lock
This example will run only one of the project's pipelines at any given time. The pipeline itself will run as normal, with all jobs running in parallel in the build stage.
Resource Group: $CI_PROJECT_NAME
# Resource Group: $CI_ENVIRONMENT_NAME for example could give you a way to run one pipeline per environment
stages:
- build
jobA:
stage: build
script:
- echo HelloA
jobB:
stage: build
script:
- echo HelloB
Edited by Brett Gadberry