Feedback

Chat Icon

Cloud Native CI/CD with GitLab

From Commit to Production Ready

Managing and Storing Data, Variables, and Secrets
46%

GitLab Environments: Tracking and Monitoring Deployments

In GitLab, an environment is a collection of related places where your code gets deployed. For example, you can have a staging environment, a production environment, a testing environment, and so on. Environments are used to track the deployment of your code and to monitor its status. You can define environments in your .gitlab-ci.yml file using the environment keyword. This is how it is done:

cat <$HOME/todo/app/.gitlab-ci.yml && \
cd $HOME/todo/app && \
git add . && \
git commit -m "Define environments" && \
git push origin main
image: python:3.12

stages:
  - deploy

deploy-staging:
  stage: deploy
  script:
    - "echo 'Deploying to staging'"
  environment:
    name: staging
    url: http://staging.example.com

deploy-production:
  stage: deploy
  script:
    - "echo 'Deploying to production'"
  environment:
    name

Cloud Native CI/CD with GitLab

From Commit to Production Ready

Enroll now to unlock all content and receive all future updates for free.