Skip to content

Auto-cancel redundant, pending/delayed pipelines

Problem to solve

We have heavy piplines to run when a MR is merged. We regularly merge multiple MRs in a short period, and hence multiple master pipelines are triggered. Moreover, in our MRs, we often do multiple pushes in short time and then wait for the pipeline to run. Most of the time, only the last pipeline matters to us.

The goal is to allow gitlab to automatically cancel redundant pipelines, which already work if the pipeline is pending. However, we would like that gitlab also cancel redundant piplines that are idle (delayed).

Further details

All our primary steps of the pipeline are delayed of 10 minutes with the following snipped:

webclient-build-master:
  ...
  only:
    - master
  when: delayed
  start_in: 10 minutes

So what we expect, if that when a MR is merge while the pipeline is hidden, the latter is being automatically cancelled. Currently, we have to cancel those idle pipelines manually.

Proposal

Consider a pipeline the same as "pending" if all of its first steps are in "idle" mode (delayed and not started, shown with a timer in CI/CD).