Limiting concurrent builds for branch
Problem to solve
Consider CI with auto-deployment step. Such situation actually happens in our environment:
-
commit 1is merged to master and startspipeline 1. -
commit 2is merged to master and startspipeline 2. -
pipeline 2runs faster thanpipeline 1, socommit 1(older) is deployed aftercommit 2(newer) - all changes from
commit 2are basically lost until next deployment.
That is clear deployment race-condition. Moreover it's not really easy to notice it. Similar problem explained in https://gitlab.com/gitlab-org/gitlab-ce/issues/26669.
Proposal
Add configuration option to limit concurrent builds for specific branch.
For example, branch master can be limited to single build at a time.
So pipeline 2 would not even start unless pipeline 1 is fully completed.
Links / references
Edited by Anton Sibilev