Maven / GitLab CI Basics Interview Questions
What are 'rules' in GitLab CI/CD and how do they control when jobs run?
The rules keyword lets you add conditions that determine whether a job is included in a pipeline, skipped, or made manual. Rules are evaluated in order - the first matching rule applies and the rest are ignored.
deploy-prod: stage: deploy script: - ./deploy.sh production rules: - if: $CI_COMMIT_BRANCH == "main" # only run on main branch when: on_success # (default) run if prior stages passed - if: $CI_PIPELINE_SOURCE == "schedule" when: on_success - when: never # never run for any other condition # Common rules patterns: job-on-mr: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" job-on-tag: rules: - if: $CI_COMMIT_TAG # runs when a git tag is pushed job-manual-on-prod: rules: - if: $CI_COMMIT_BRANCH == "main" when: manual # must be manually triggered in UI job-with-changes: rules: - changes: # only run if these files changed - src/**/* - package.json job-allow-fail: rules: - if: $CI_COMMIT_BRANCH == "main" allow_failure: true # pipeline passes even if this fails
| Value | Behaviour |
|---|---|
| on_success (default) | Run if all prior jobs in pipeline passed |
| on_failure | Run only if a prior job failed |
| always | Run regardless of prior job status |
| never | Never add this job to the pipeline |
| manual | Add job but require manual trigger to start |
| delayed | Run after a specified delay |
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...
