Gitlab: How to cancel redundant pipelines

Updated . Posted . Visible to the public. Repeats.

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.

Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2023-12-19 10:36)