Skip to content

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

Screenshots or screen recordings

Peek_2023-08-22_15-56

How to set up and validate locally

  1. Enable support_ci_environment_variables_in_job_rules feature flag.
  2. Create a project.
  3. Add .gitlab-ci.yml with 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"
  4. Make sure a pipeline with the deploy job 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.

Edited by Shinya Maeda

Merge request reports

Loading