What are GitLab environments and how do deployments get tracked?
IntermediateConceptGitLab CI
Answer
A job with the environment: keyword creates or updates an environment, recording each deployment with its commit and URL. You get deployment history, one-click rollback (re-run an older deployment job), and optional protected environments requiring approvals. Dynamic environments (review apps) use environment: name: review/$CI_COMMIT_REF_SLUG with an on_stop job to tear them down.
deploy-prod:
stage: deploy
script: ./deploy.sh
environment:
name: production
url: https://app.example.com
when: manual
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