Allow template variables to be used in dynamic environments name and url

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Currently an environment can be created dynamically using some variables, quoting the doc:

Allowed variables

The name and url keywords for dynamic environments can use most available CI/CD variables, including:

    Predefined environment variables
    Project and group variables
    .gitlab-ci.yml variables 

Which looks to forbid using variables from templates, making this fail (silently: i see no error, but the env is not created, probably due to the invalid '$' character in it?):

.staging:
  stage: staging
  environment:
    name: $subdomain
    url: https://$subdomain.example.com
deploy master to staging:
  extends: .staging
  only:
    - master
  variables:
    subdomain: ${STAGING_SUBDOMAIN}

deploy branch to staging:
  extends: .staging
  except:
    - master
  variables:
    subdomain: ${CI_COMMIT_REF_SLUG}-${STAGING_SUBDOMAIN}

I tried by templating it myself, and it worked, so it really looks related to a template variable issue.

Edited by 🤖 GitLab Bot 🤖