Maven / GitLab CI Basics Interview Questions
What are GitLab environments and how do you define them in CI/CD?
Environments in GitLab CI/CD represent deployment targets - staging, production, review apps, etc. Defining an environment in a job links that deployment to the environment, enabling GitLab to track which version is deployed where and provide rollback capabilities.
# Basic environment definition deploy-staging: stage: deploy script: - ./deploy.sh staging environment: name: staging url: https://staging.example.com rules: - if: $CI_COMMIT_BRANCH == "main" deploy-production: stage: deploy script: - ./deploy.sh production environment: name: production url: https://example.com rules: - if: $CI_COMMIT_TAG when: manual # requires manual approval # Dynamic review environments per merge request review-app: stage: deploy script: - deploy-to-review.sh $CI_COMMIT_REF_SLUG environment: name: review/$CI_COMMIT_REF_SLUG url: https://$CI_COMMIT_REF_SLUG.review.example.com on_stop: stop-review rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" stop-review: stage: deploy script: - teardown-review.sh $CI_COMMIT_REF_SLUG environment: name: review/$CI_COMMIT_REF_SLUG action: stop rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" when: manual
Environments are visible under Deploy > Environments in the GitLab UI, showing the current deployed version, who deployed it, and when. The on_stop option links a cleanup job that tears down ephemeral environments (like review apps) when no longer needed.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
