Maven / GitLab CI Basics Interview Questions
What is a merge request pipeline in GitLab CI and how does it differ from a branch pipeline?
GitLab supports two types of pipelines related to merge requests: branch pipelines (triggered by a push to a branch) and merge request pipelines (triggered specifically by merge request events). Understanding the difference is essential for designing efficient review workflows.
| Aspect | Branch Pipeline | Merge Request Pipeline |
|---|---|---|
| Trigger | Push to a branch | MR created, updated, or rebased |
| Source variable | push | merge_request_event |
| Runs on | The feature branch's HEAD | Merge result (branch + target merged) |
| MR status checks | Not shown in MR (unless configured) | Shown in MR as status checks |
| MR variables | $CI_MERGE_REQUEST_* not set | $CI_MERGE_REQUEST_* fully populated |
| Merged result | Tests the branch as-is | Tests what the code will look like after merge |
# Jobs that run only in MR pipelines: code-review: script: - run-code-quality.sh rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Useful MR-specific variables: check-mr: script: - echo "MR ID: $CI_MERGE_REQUEST_ID" - echo "Target branch: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME" - echo "Source branch: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - echo "MR title: $CI_MERGE_REQUEST_TITLE" rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Merged results pipeline (tests the post-merge state): # Enable in Settings > Merge requests > Merged results pipelines # Runs on the merge commit that would result from accepting the MR
Merged results pipelines (enabled in project settings) run the CI on the simulated merge result - catching conflicts between the MR branch and the target branch that would only appear after merging. This is safer than testing just the source branch.
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...
