Canceling redundant CI/CD pipelines early is a good practice that prevents wasteful use of runners.
GitLab CI/CD has a feature to auto-cancel redundant pipelines that can be activated on a per project basis.
The setting can be found at in the project settings under CI/CD > General Pipelines > Auto-cancel redundant pipelines.
Once this setting is activated, you may set the interruptible
property on individual jobs—or, in the default
section to apply it to all jobs—to mark jobs that should be canceled if a newer commit was pushed to the same ref (e.g. to the same branch).
The executed interruption logic may be configured using the top-level property workflow:auto_cancel:on_new_commit
. There are three options:
conservative
(default): cancels the pipeline only if no jobs withinterruptible: false
are already running;interruptible
: only cancels jobs marked withinterruptible: true
; andnone
: does not auto-cancel any jobs.
Enabling auto-cancel of pipelines on new commits to the same ref is generally sensible and should, in my opinion, be considered a standard setting. It is probably best, though, to start with workflow:auto_cancel_on_new_commit: interruptible
and then iteratively defining jobs as interruptible to keep a watchful eye on the effects.