Maven / GitLab CI Basics Interview Questions
What is the 'workflow' keyword in GitLab CI and how does it control pipeline creation?
The workflow keyword controls whether an entire pipeline is created at all, based on conditions. While rules on individual jobs control whether a specific job runs, workflow: rules controls whether the entire pipeline is created for a given event.
# Only create pipelines for main branch, MRs, and tags workflow: rules: - if: $CI_COMMIT_BRANCH == "main" - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_TAG - when: never # suppress all other pipeline triggers # Name the pipeline dynamically workflow: name: "Pipeline for $CI_COMMIT_REF_NAME" rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" name: "MR Pipeline: $CI_MERGE_REQUEST_TITLE" - if: $CI_COMMIT_BRANCH # Prevent duplicate pipelines (MR + branch pipelines) # This is a very common pattern: workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never # skip branch pipeline when MR pipeline exists - if: $CI_COMMIT_BRANCH
Preventing duplicate pipelines: by default, pushing to a branch that has an open MR creates two pipelines - a branch pipeline and an MR pipeline. The pattern above suppresses branch pipelines when an MR is open, avoiding redundant CI runs that waste runner minutes.
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...
