Skip to content

Implement variables for pipeline job rules

Furkan Ayhan requested to merge 209864-variables-in-pipeline-rules into master

What does this MR do?

Related to #209864 (closed)

This MR implements the variables keyword for rules of pipeline jobs. This is only for jobs, next MR will implement for workflow:rules.

This is behind a feature flag ci_rules_variables (#289803 (closed))

Screenshots (strongly suggested)

job:
  script: "echo job1"
  variables:
    VAR1: my var 1
    VAR2: my var 2
  rules:
    - if: $CI_COMMIT_REF_NAME =~ /master/
      variables:
        VAR1: overridden var 1
    - if: $CI_COMMIT_REF_NAME =~ /feature/
      variables:
        VAR2: overridden var 2
        VAR3: new var 3
    - when: on_success

If the first condition is satisfied, then the total variables will be:

- VAR1: overridden var 1
- VAR2: my var 2

If the second condition is satisfied, then the total variables will be:

- VAR1: my var 1
- VAR2: overridden var 2
- VAR3: new var 3

If no condition is satisfied, then the total variables will be:

- VAR1: my var 1
- VAR2: my var 2

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Furkan Ayhan

Merge request reports