Gitlab: How to cancel redundant pipelines

In the Gitlab settings Show archive.org snapshot the flag Auto-cancel redundant pipelines is enabled by default. This auto-cancels jobs that have the interruptible setting set to true (defaults to false e.g. to not cancel deploys by accident).

Consider to set the interruptible flag for test jobs to reduce the load on your runners like in the following example .gitlab-ci.yml:

rubocop:
  interruptible: true
  script:
    - 'bundle exec rubocop'

rspec:
  interruptible: true
  script:
    - 'bundle exec rspec'

Afterwards new pushes to your MR will cancel all running interruptible jobs the previous pipelines and start a new pipeline with the current commit.

Tip

Instead of configuring jobs to be interruptible by default, you can also setup your .gitlab-ci.yml so commit messages with a string like no-ci don't start a new CI pipeline.

Emanuel 4 months ago