Skip to content

Add support for `when: always` on conditional includes

Leaminn Ma requested to merge add-include-rules-when-always into master

What does this MR do and why?

In !122810 (merged), we added support for when: never on conditional includes. This MR adds support for when: always, which has the same behaviour as when you do not specify when.

The file is included into the pipeline if:

  • If a rule match and a when: value is not set.
  • If a rule matches and has when: always.

If there are no rules, the file is included as expected. Also note that when: null behaves the same as not specifying when:.

Feature flag: ci_support_include_rules_when_never

Implementation:

Resolves #348146 (closed).

How to set up and validate locally

  1. Add two config files to your project root:

config1.yml:

job1:
  script: echo

config2.yml:

job2:
  script: echo
  1. Turn on the Feature Flag: Feature.enable(:ci_support_include_rules_when_never).
  2. Update your .gitlab-ci.yml file with the following contents:
include:
  - local: config1.yml
    rules:
      - if: $VAR == null
        when: always
  - local: config2.yml
    rules:
      - if: $VAR == null

job0:
  script: echo
  1. Run the pipeline and observe that all 3 jobs are present.
Screenshot Screenshot_2023-06-06_at_4.42.59_PM

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #348146 (closed)

Edited by Leaminn Ma

Merge request reports