Teams need review apps for every MR and auto-stop when the MR closes.
IntermediateScenarioGitLab CI
Answer
Situation read → Dynamic environments.
What I'd do →
review:
script: ./deploy-review.sh $CI_ENVIRONMENT_SLUG
environment:
name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.review.example.com
on_stop: stop_review
auto_stop_in: 3 days
rules: [{ if: $CI_PIPELINE_SOURCE == "merge_request_event" }]
stop_review:
script: ./teardown.sh $CI_ENVIRONMENT_SLUG
environment: { name: review/$CI_COMMIT_REF_SLUG, action: stop }
when: manual
Why → auto_stop_in and on_stop prevent orphaned environments.
Interview tip → Always pair environment creation with a stop path.
More on GitLab CI
How does GitLab CI/CD work at a high level?BeginnerWhat is a GitLab Runner and what executors exist?IntermediateWhat are the types of runners (shared, group, project) and tags?IntermediateHow do `rules:` work and how do they replace `only/except`?IntermediateWhat are workflow rules and how do they prevent duplicate pipelines?AdvancedHow do artifacts and cache differ in GitLab CI?Intermediate