Skip to content

Support variables in rules: exists

Laura Montemayor requested to merge variables-rules-exist into master

What does this MR do and why?

Support variable expansion in rules: exists. This change is under the feature flag ci_variable_expansion_in_rules_exists.

Screenshots or screen recordings

When the rules match:

variables:
  PATTERN: '*.yml'
  WRONG_PATH: 'wrong.rb'
rule_exist_job:
 script: 
    - echo $PATTERN
    - echo $WRONG_PATH
    - echo $EXIST_PATH
 rules:
    - exists:
      - $PATTERN

In the example above, we have an existing deploy.yml file, so the rule_exist_job runs:

Screenshot_2022-11-01_at_15.33.42

When the rules do not match:

variables:
  PATTERN: '*.yml'
  EXIST_PATH: 'upload.yml'
  WRONG_PATH: 'wrong.rb'
rule_exist_job:
 script: 
    - echo $PATTERN
    - echo $WRONG_PATH
    - echo $EXIST_PATH
 rules:
    - exists:
      - $PATTERN

There are no jobs for this pipeline:

Screenshot_2022-11-01_at_15.34.27

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: #283881 (closed)
Rollout issue: #381046 (closed)

Edited by Laura Montemayor

Merge request reports