Checkpoint Lab — Merge Request Pipelines, Merged Results Pipelines, Merge Trains, and Pre-Merge Validation
The checkpoint builds a safe MR validation contract: one intended pipeline per MR update, exact source/ref/SHA evidence, no protected-resource assumptions, a deliberate duplicate/wrong-source failure, and a repair that proves which code state is actually merge-gated.
Learning objectives
- Predict pipeline creation and job inclusion for push and merge-request events before running the checkpoint.
- Prove the exact MR ref and pipeline SHA used by the successful validation run.
- Capture a deliberate duplicate or wrong-source pipeline as evidence and repair only its causal rule.
- Produce a safe evidence packet without variables, tokens, credentials, or proprietary data.
- Bridge reliable pre-merge identity into Chapter 17 parallelism and test sharding without multiplying ambiguous work.
1. Checkpoint scenario and success criteria
You own a disposable project whose team wants one trustworthy pre-merge signal. The current configuration sometimes creates branch and MR pipelines for the same feature push. Your task is to:
- create a safe MR validation pipeline on the Free path;
- predict which pipeline sources should and should not exist;
- prove the exact MR ref/SHA under test;
- capture one deliberate duplicate/wrong-source failure;
- repair only the causal rule;
- produce a compact evidence packet suitable for review.
2. Current assumptions and preflight
- Documentation verified: 2026-09-11.
- Mandatory feature: ordinary MR pipelines (Free/Premium/Ultimate).
- Optional/simulated: merged-results pipelines and merge trains (Premium/Ultimate).
-
Example container image:
alpine:3.22.1; record the actual runner/executor/image reported by your job. - No real secrets, deployments, production runners, or external systems.
Record the disposable project path, default branch, feature branch, current source SHA, and planned MR target before changing CI.
3. Write predictions before running
Write at least these predictions:
-
With the deliberately broken workflow, a feature push with an open
MR can create both
pushandmerge_request_eventpipelines. - After the repair, a feature-branch update creates exactly one MR pipeline; the feature push pipeline is suppressed, while a post-merge default-branch pipeline remains allowed.
-
The successful MR pipeline’s recorded
CI_COMMIT_SHAmatches the intended feature revision for this ordinary MR pipeline. -
CI_MERGE_REQUEST_REF_PATHis present in the MR pipeline and absent in the branch pipeline.
4. Phase A — reproduce the bad evidence state
Use this intentionally broad configuration first:
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH'
stages: [verify]
pre_merge_evidence:
image: alpine:3.22.1
stage: verify
script:
- mkdir -p evidence
- printf 'pipeline_id=%s\n' "$CI_PIPELINE_ID" | tee evidence/context.txt
- printf 'job_id=%s\n' "$CI_JOB_ID" | tee -a evidence/context.txt
- printf 'source=%s\n' "$CI_PIPELINE_SOURCE" | tee -a evidence/context.txt
- printf 'sha=%s\n' "$CI_COMMIT_SHA" | tee -a evidence/context.txt
- printf 'ref=%s\n' "$CI_COMMIT_REF_NAME" | tee -a evidence/context.txt
- printf 'mr_iid=%s\n' "${CI_MERGE_REQUEST_IID:-none}" | tee -a evidence/context.txt
- printf 'mr_ref=%s\n' "${CI_MERGE_REQUEST_REF_PATH:-none}" | tee -a evidence/context.txt
- printf 'event_type=%s\n' "${CI_MERGE_REQUEST_EVENT_TYPE:-none}" | tee -a evidence/context.txt
- test -f src/app.conf
artifacts:
paths: [evidence/context.txt]
expire_in: 2 days
With an open MR, push one harmless source change. Record both
pipeline IDs if both are created. Download or inspect each
evidence/context.txt and label one as branch-context
evidence and the other as MR-context evidence.
5. Diagnose without deleting either pipeline
Confirm:
- the two pipelines share the same source commit or source-branch update;
-
one has source
pushand no MR ref; the other has sourcemerge_request_eventand MR metadata; - the compiled workflow admits both sources;
- runner capacity is not the cause.
The original branch pipeline is now an evidence artifact for the defect. Keep its ID in your checkpoint notes.
6. Phase B — enforce the intended source contract
Replace only the workflow rules:
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- when: never
Keep the evidence job otherwise unchanged. Push another harmless feature commit. Verify that the feature update creates the intended MR pipeline but no parallel feature-branch push pipeline.
7. Prove the successful candidate independently
For the repaired MR pipeline, collect these values from at least two independent locations where possible:
| Evidence | Job artifact/log | Pipeline/MR UI or API |
|---|---|---|
| Pipeline ID | CI_PIPELINE_ID | Pipeline record |
| Pipeline source | CI_PIPELINE_SOURCE | Pipeline source/label |
| Exact SHA | CI_COMMIT_SHA | Pipeline SHA |
| MR IID | CI_MERGE_REQUEST_IID | Merge request IID |
| MR ref path | CI_MERGE_REQUEST_REF_PATH | Pipeline/ref details where shown |
| Event type | CI_MERGE_REQUEST_EVENT_TYPE | Pipeline type label/context |
The feature branch name is useful context but not sufficient proof because it can move after the pipeline finishes.
8. Optional integration-state extension
If you have no Premium/Ultimate disposable project, run the local temporary-merge simulation from Lesson 2 and include its source parent, target parent, and simulated merge SHA in the evidence packet under a simulation heading.
If you do have an authorized Premium/Ultimate project, you may
instead observe a merged-results pipeline and record its temporary
CI_COMMIT_SHA plus event type. Merge-train observation
is optional; do not alter a production project merely for the
checkpoint.
9. Evidence packet
Project path, MR IID, source/target branches
Duplicate/wrong-source pipeline IDs and source values
Exact workflow:rules diff and new commit SHA
MR pipeline ID, job ID, CI_COMMIT_SHA, MR ref path, event type
Relevant workflow and job inclusion result
Runner description/ID where visible, executor, image tag
Merged-result/train observation OR clearly labeled local simulation
Tier, project settings, no protected secrets/resources used
10. Verification checklist
- The repaired feature update creates one intended MR pipeline.
- The MR pipeline source is
merge_request_event. - The MR IID/ref evidence is present and the pipeline SHA is recorded.
- The old duplicate pipeline remains identifiable in notes as first-failure evidence.
- No protected variable or production runner was required.
- Any merged-result behavior is either truly observed in an authorized Premium/Ultimate project or explicitly labeled as simulation.
- Pipeline success is not claimed as proof of deployment/external health.
11. Cleanup/rollback
- Close the disposable MR after capturing the final evidence.
- Delete the local simulation worktree if used.
- Delete only the exact disposable feature branch/project after checking identity.
- If optional merged-results/train settings were changed in a disposable project, restore the prior setting and note the rollback.
- Do not bulk-delete pipelines or artifacts; preserve the checkpoint evidence until review is complete.
12. What Chapter 16 adds to the production operating model
You can now distinguish source-branch success from integrated-candidate success, prove the exact commit/ref under test, keep fork code outside privileged resource boundaries, avoid duplicate pipeline creation, and interpret merged-results/merge-train evidence without confusing it with deployment health or governance approval.
Chapter 17 builds on this identity discipline when one logical test suite expands into many parallel jobs and matrix combinations. Parallelism is useful only if every shard still belongs to the same well-defined source/integration candidate and its evidence can be recombined without ambiguity.
Knowledge check
What is the most important checkpoint evidence field after pipeline ID?
The exact pipeline SHA/ref context, because it identifies the code state actually validated rather than the branch name as it exists later.
Why preserve the duplicate pipeline instead of deleting it immediately?
Its ID/source/ref/SHA is first-failure evidence proving the workflow admitted an unintended pipeline context.
What should the repaired workflow permit for feature-branch MR updates in this checkpoint?
The merge_request_event pipeline, while suppressing a parallel feature-branch push pipeline; default-branch pipelines remain allowed after merge.
Can a local temporary merge be labeled “merged-results pipeline”?
No. It is a faithful integration simulation only; it does not reproduce GitLab project settings, temporary ref identity, event variables, or mergeability state.
What concept must carry into Chapter 17?
Every parallel shard must retain the same unambiguous pipeline/source/SHA candidate identity and produce recombinable evidence.
Version and compatibility note
GitLab and GitLab Runner evolve continuously. Treat version-sensitive YAML, runner/executor behavior, APIs, security features, policy controls, tiers, and deprecations as assumptions to verify against the current official GitLab documentation before production use. Preserve the exact project/ref/SHA, compiled configuration, pipeline/job IDs, runner/tool versions, and external target evidence used for any reproducible lab or incident record.
Official references and version notes
Documentation verification date: 2026-09-11. Merge-request pipeline behavior, protected-resource access, merged-results pipelines, merge trains, predefined variables, and merge checks are version-sensitive. Re-check the deployed GitLab version and project settings before using these patterns in production.
- Merge request pipelines — prerequisites, source-branch behavior, fork pipelines, parent-project execution, and protected resources.
- Merged results pipelines — temporary merged commits and current Premium/Ultimate availability.
- Merge trains — queue semantics, temporary integration state, current parallel limits, and enforcement options.
- Types of pipelines — branch, MR, merged-results, merge-train, parent/child, and multi-project distinctions.
-
Predefined variables reference
— MR ref/source/target variables and
CI_MERGE_REQUEST_EVENT_TYPE. -
CI/CD YAML syntax reference
— authoritative
workflow:rules,rules,changes, and job semantics. - Debugging CI/CD pipelines — CI Lint, compiled configuration, pipeline naming, and evidence-first troubleshooting.
- Protected branches — permissions and CI/CD implications for protected refs.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0
Send only Ethereum/ERC-20 compatible assets to this
address.