Skip to content

Support `interruptible` in CI config job rules

Leaminn Ma requested to merge ci-support-interruptible-in-rules into master

What does this MR do and why?

This MR adds the ability to override a job's interruptible value using rules.

Resolves #194023 (closed).

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. First let's observe what happens when a job's rules does not override its interruptible value. Commit the following change to your project's .gitlab-ci.yml and then make another commit (within 60 seconds) to the same branch.
job:
  interruptible: true
  script: sleep 60
  1. Step 1 would have triggered two pipelines, the first of which should be canceled because interruptible: true.

Screenshot_2024-02-13_at_12.02.00_PM

  1. Now commit the following to your .gitlab-ci.yml and again make another commit (within 60 seconds) to the same branch.
job:
  interruptible: true
  script: sleep 60
  rules:
    - if: $EMPTY == null # true
      interruptible: false
  1. Step 3 would again trigger two pipelines except this time the first pipeline does not get canceled. This confirms that the job's interruptible value was overridden by the rule and updated to false.

Screenshot_2024-02-13_at_12.04.29_PM

  1. Since interruptible can also be set at the default level, we can repeat Step 3 with the following config. The output should be the same as in Step 4.
default:
  interruptible: true

job:
  script: sleep 60
  rules:
    - if: $EMPTY == null # true
      interruptible: false

Related to #194023 (closed)

Edited by Leaminn Ma

Merge request reports