Skip to content

Backend: Add support for `when: never` on conditional includes

Release notes

With the implementation of #276515 (closed) users could decide when to include a yaml configuration to their pipeline, however in some cases users would like to decide when not to include their configuration on given condition

Currently, we support the following syntax

include:
  - local: somefile.yml
    rules:
      - if: $CI_MERGE_REQUEST_LABELS =~ /(^|,)ci minimal($|,)/

which will include somefile.yml if the rules is satisfied

Proposal

include:
  - local: somefile.yml
    rules:
      - if: $CI_MERGE_REQUEST_LABELS =~ /(^|,)ci minimal($|,)/
        when: never  # add this support

which will exclude somefile.yml if the rules is satisfied

workaround

include:
  - local: somefile.yml
    rules:
      - if: $CI_MERGE_REQUEST_LABELS !~ /(^|,)ci minimal($|,)/

This workaround should work however, it might be a bit complex when involving multiple rules

Implementation

Description MR / Issue
Add support for when: never on conditional includes. Feature flag: ci_support_include_rules_when_never !122810 (merged)
Add support for when: always on conditional includes. Feature flag: ci_support_include_rules_when_never !123443 (merged)
[Feature flag] Roll out ci_support_include_rules_when_never #414517 (closed)
Edited by Leaminn Ma