Skip to content

Auto-cancel redundant pipelines when a new pipeline runs

When multiple parallel pipelines run on the same branch, the faster pipeline would clean the images that the slower pipelines still need, causing those pipelines to fail due to missing images.

GitLab provides an Auto-cancel redundant pipelines feature (Settings > CI/CD > General pipelines). This feature allows us to set pending or running pipelines to cancel automatically when a pipeline for new changes runs on the same branch.

By default, when checked, it is set to conservative (workflow: auto_cancel: on_new_commit: conservative) [1], which implies:

Cancel the pipeline, but only if no jobs with interruptible: false (default if not mentioned) have started yet

This default behavior is not helpful for our use case since the clean images job runs at the end. To work around this, we set the clean images job as interruptible: true, and set auto_cancel to interruptible, which implies:

Cancel only jobs with interruptible: true

Note: This setting works as expected, and the clean images job is canceled automatically. However, this still wastes resources as redundant pipelines still run until they reach the clean images job. A better solution might be to set default: interruptible: true. Whether this is a good choice is debatable.

Previous attempt: !602 (closed)

Closes #289 (closed)

Edited by Aayush Raj

Merge request reports

Loading