Support environment keyword with trigger keyword
This MR is built on top of Support environment predefined variables in job... (!128694 - merged)
What does this MR do and why?
This MR introduces a support for environment
keyword to be combined with trigger
keyword (a.k.a. downstream pipelines).
It's a very simple change that moving the environment
config entry to the processable superclass, so that it supports both build and bridge job types. Nevertheless, good amount of integration tests are added so that we can verify that the feature works in various configurations.
All of the fundamental works have already been done in the previous MRs, which you can see in the main issue Support `environment` keyword with `trigger` ke... (#369061 - closed).
Screenshots or screen recordings
How to set up and validate locally
- Enable
support_ci_environment_variables_in_job_rules
feature flag. - Activate EEU license in the GitLab instance.
- Create upstream and downstream projects.
- Add following
.gitlab-ci.yml
in the downstream project.provisioning: script: export rules: - if: $CI_PIPELINE_SOURCE == "pipeline" && $UPSTREAM_ENVIRONMENT_ACTION == "start" teardown: script: export rules: - if: $CI_PIPELINE_SOURCE == "pipeline" && $UPSTREAM_ENVIRONMENT_ACTION == "stop"
- Add following
.gitlab-ci.yml
in the upstream project.stages: - deploy - cleanup .downstream-deployment-pipeline: variables: UPSTREAM_PROJECT_ID: $CI_PROJECT_ID UPSTREAM_ENVIRONMENT_NAME: $CI_ENVIRONMENT_NAME UPSTREAM_ENVIRONMENT_URL: $CI_ENVIRONMENT_URL UPSTREAM_ENVIRONMENT_ACTION: $CI_ENVIRONMENT_ACTION UPSTREAM_ENVIRONMENT_TIER: $CI_ENVIRONMENT_TIER trigger: project: multi-project-deployment-pipelines/downstream-project branch: main strategy: depend deploy-review: stage: deploy extends: .downstream-deployment-pipeline environment: name: review/$CI_COMMIT_REF_SLUG on_stop: stop-review stop-review: stage: cleanup extends: .downstream-deployment-pipeline environment: name: review/$CI_COMMIT_REF_SLUG action: stop when: manual
- Make sure the upstream pipeline runs correctly and triggers the downstream pipeline.
- Make sure the downstream pipeline has deployment context such as
UPSTREAM_ENVIRONMENT_NAME
.
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.