Implement variables for pipeline workflow rules [RUN ALL RSPEC] [RUN AS-IF-FOSS]
Compare changes
This is another approach for #294232 (closed). First approach: !50682 (closed).
Refactor has been done before this MR => !57136 (merged)
This MR implements the variables
keyword for rules
of pipeline workflow. This is only for workflow:rules, the previous MR implemented for job:rules
.
root_variables
to Pipeline::Chain::Command
to store variables defined in YAML.
result.workflow_attributes[:yaml_variables]
in lib/gitlab/ci/pipeline/chain/config/process.rb
.lib/gitlab/ci/pipeline/chain/evaluate_workflow_rules.rb
that applying rules for workflow by changing the root_variables
of Pipeline::Chain::Command
.lib/gitlab/ci/config/entry/processable.rb
that merging root variables with job variables.
variables
attribute the same for now. It will be removed with #300581 (closed).job_variables
return only job variables.variable_inheritance
to handle this in seed/build
.lib/gitlab/ci/pipeline/seed/build.rb
to override only variables from root
.Why did I choose this way?
inherit
logic is in lib/gitlab/ci/config/entry/processable.rb
.rules
in the "create pipeline" logic and we need that result to override workflow variables.rules
to override the job variables from the workflow.workflow:variables
/workflow:rules:variables
in seed/build
.ci_workflow_rules_variables
feature flag issue => #300997 (closed)
variables:
VAR1: my var 1
VAR2: my var 2
workflow:
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: always
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
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:
@gitlab-com/gl-security/appsec