Feature proposal: Variable expansion in deployment_tier
Proposal
Support variable expansion in the environment:deployment_tier field of a job in the .gitlab-ci.yml.
Use Case
When a child pipeline is triggerd (dynamic or static) and then used to deploy to multiple environments.
.gitlab-ci-deploy.yml
service-a:
environment:
name: $ENVIRONMENT/service-a
deployment_tier: $DEPLOYMENT_TIER
script:
- ./deploy.sh
.gitlab-ci.yml
deploy:
variables:
ENVIRONMENT: nonprod
DEPLOYMENT_TIER: staging
trigger:
include: .gitlab-ci-deploy.yml
deploy-prod:
variables:
ENVIRONMENT: prod
DEPLOYMENT_TIER: production
trigger:
include: .gitlab-ci-deploy.yml
Implementation
The code for fetching the tier is in Ci::Deployable#environment_tier_from_options. This needs to be updated to use ExpandVariables on the configured value. See #expanded_environment_name and #expanded_kubernetes_namespace for existing examples.
In order to preserve validation integrity, this blocked until GitLab has upgraded to Rails 7.1, see #365402 (comment 2200490852) for details. (Ref: Blocked by the apic Rails 7.1 upgrade (&11470))
Edited by 🤖 GitLab Bot 🤖