Skip to content

Implement nested expanding environment name and url for deployments

Furkan Ayhan requested to merge 293674-expand-environment-name-url into master

What does this MR do and why?

We support variables for YAML attributes of environment:name and environment:https://docs.gitlab.com/ee/ci/yaml/#environmenturl. However, we expand those variables by only 1-level.

In this MR, we start supporting infinite level expansion.

These changes are behind a FF ci_expand_environment_name_and_url (#358831 (closed))

Related to #293674 (closed)

How to set up and validate locally

  1. Use this example CI config:
production:
  script:
    - echo $CI_COMMIT_REF_SLUG
    - echo $ENVIRONMENT_NAME
    - echo $STACK_NAME
    - echo $MAIN_DOMAIN
    - echo $CI_ENVIRONMENT_NAME
    - echo $CI_ENVIRONMENT_URL
  variables:
    ENVIRONMENT_NAME: ${CI_COMMIT_REF_SLUG}
    STACK_NAME: appname-${ENVIRONMENT_NAME}
    MAIN_DOMAIN: ${STACK_NAME}.example.com
  environment:
    name: ${ENVIRONMENT_NAME}
    url: https://${MAIN_DOMAIN}
  1. Run the pipeline.

Output:

Screen_Shot_2022-04-12_at_18.12.04

It looks fine because they are expanded in the Runner side.

  1. See the /-/environments path of the project

Screen_Shot_2022-04-12_at_18.12.15

Notice that there is not an "Open" button because the URL was not properly parsed.

  1. Enable the FF ci_expand_environment_name_and_url

See the /-/environments path of the project

Screen_Shot_2022-04-12_at_18.12.26

Notice that there is an "Open" button.

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 Furkan Ayhan

Merge request reports