Support environment predefined variables in job rules
What does this MR do and why?
This MR supports CI_ENVIRONMENT_NAME, CI_ENVIRONMENT_ACTION, CI_ENVIRONMENT_TIER and CI_ENVIRONMENT_URL variables in job rules. This is also necessary to pass upstream environment context to the downstream pipeline in Support environment keyword with trigger keyword (!128693 - merged).
This change is behind support_ci_environment_variables_in_job_rules feature flag and it's disabled by default.
Related to
- Support `environment` keyword with `trigger` ke... (#369061 - closed)
- Add support for CI_ENVIRONMENT_NAME to be used ... (!106093 - merged)
- Support environment keyword with trigger keyword (!128693 - merged)
Screenshots or screen recordings
How to set up and validate locally
- Enable
support_ci_environment_variables_in_job_rulesfeature flag. - Create a project.
- Add
.gitlab-ci.ymlwith the following content:deploy: script: "deploy" environment: name: review/$CI_COMMIT_REF_NAME deployment_tier: development url: https://gitlab.com rules: - if: $CI_ENVIRONMENT_NAME =~ /^review\// && $CI_ENVIRONMENT_ACTION == "start" && $CI_ENVIRONMENT_TIER == "development" && $CI_ENVIRONMENT_URL == "https://gitlab.com" - Make sure a pipeline with the
deployjob is created.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Shinya Maeda