START
HERE
Table of Contents
🗺️ The Map — The Whole Route
Three chapters, one line: Foundations draws the pipeline every merge travels; Source Control builds the gate that guards it; Integration turns the gate into daily discipline.
What CI/CD Actually Is
CI/CD is automation plus discipline: every commit verified by machines, every release decided by policy. One line: commit → CI → artifact → CD → observe.
| Practice | Question it answers |
|---|---|
| Continuous Integration | Does this change work — build, test, scan green? |
| Continuous Delivery | Is it releasable — staged auto, prod by approval? |
| Continuous Deployment | Did it ship — prod automatic, rollback armed? |
| GitOps | Is reality matching git — pull, drift-corrected? |
⏭️ Next: Foundations
Foundations
A pipeline is not magic.
It is a deterministic sequence of machines making decisions about your code — from the moment you push to the moment users feel the change.
1 / The CI/CD Lifecycle
2 / How to read this manual
Each concept answers WHAT · WHY · WHEN · HOW · WHAT CAN FAIL. Green means passed, red means failed, amber means a human must decide, purple means artifact. Color always pairs with a symbol and a label — the book survives grayscale printing.
Continuous Integration
3 / What Is Continuous Integration
Developers merge small changes into shared main frequently; every merge triggers an automated build + test + scan. CI answers one question: does this change work?
WHEN — on every push and every pull request. HOW — a pipeline job checks out the exact commit, builds it in a clean environment, and reports green or red back to the branch in minutes.
Without automated integration, a broken change travels for days before anyone discovers it. CI moves that discovery to within minutes of the commit — when the author still remembers what they did.
4 / What happens without CI/CD
- Long-lived branches → merge hell. Weeks of divergent work collide; untangling takes days.
- "Works on my machine" releases. Testing one thing, shipping another — every deploy a gamble.
- Manual testing → bugs reach users. Humans skip steps under pressure.
- Manual deploys → release fear. Rare, big, traumatic events nobody runs on Friday.
- No feedback loop. The same bug class ships again and again.
Integration pain is paid minutes per commit with CI/CD, or weeks per release without it.
CI vs CD · Delivery vs Deployment
5 / CI vs Delivery vs Deployment
| CI | Continuous Delivery | Continuous Deployment | |
|---|---|---|---|
| Question | Does it work? | Could we ship it? | — (ships itself) |
| Trigger | Commit / merge | Validated artifact | Validated artifact |
| Human gate | No | Yes — approval | No |
| Output | Verified code | Releasable artifact | Production deployment |
A green build does not mean the application works in production. It means only the checks inside that pipeline passed.
Pipeline & Status
6 / Anatomy of a Pipeline
Stages are phases, jobs are units of work inside them, steps are single operations, runners are the machines. Progression reads left to right; a red stage blocks everything downstream.
| Term | Meaning |
|---|---|
| Pipeline | The automated workflow |
| Stage | Logical phase (build, test, deploy) |
| Job | Unit of executable work inside a stage |
| Step | Single operation inside a job |
| Runner / Agent | Execution environment running the work |
7 / The Status System
Environments & Flow
8 / Environment Lanes: One Artifact, Three Tracks
9 / The Deployment Loop
Console
10 / From Push to Pipeline
$ git push origin main
→ pipeline triggered · commit 9f3a2c1
[01] BUILD PASSED 1m 12s
[02] TEST RUNNING · 214/300
[03] SCAN WAITING
[04] ARTIFACT WAITING
11 / Command and Result
COMMAND
$ docker build -t registry/app:sha-9f3a . $ docker push registry/app:sha-9f3a
RESULT
Successfully built 7f91c2 Successfully tagged sha-9f3a Pushed digest sha256:4d…e9
Artifact & Gate
12 / The Artifact Identity
13 / The Approval Gate
The build pipeline produces the artifact; the deployment pipeline consumes it; the registry stores it. Lifecycle: build → store → promote → deploy. Anything that breaks this chain — a rebuild, a mutable tag, a skipped gate — voids every check upstream.
Failure & Recovery
14 / Failure as a State Transition
FAILURE → LOGS → ROOT CAUSE → FIX → NEW COMMIT → PIPELINE. Every incident must land a new check, or it will recur.
Never bypass a red gate with an admin override "just this once". The override becomes the process.
Check & Map
15 / Interview Check
Delivery keeps software production-ready behind an approval; Deployment releases validated changes automatically.
Otherwise you tested one binary and shipped another — verification is void.
16 / The CI/CD System Map
Source Control
Picking up from Foundations, where a Git push triggered the lifecycle — we now examine the machinery of that trigger: branches isolate work, pull requests gate it, triggers fire pipelines.
01 / What Each Piece Is
Git — distributed version control; every commit is a snapshot with author, message, parent.
Branching — an independent line of work (feature/login) forked from main.
Pull Request — a merge proposal combining human review with automated status checks.
CI Trigger — the event that starts a pipeline: PR opened/updated, push to main, schedule, manual.
02 / Why the Gate Exists
Direct pushes to main bypass review and verification. The branch → PR → CI → merge flow makes every change Reviewed, Tested, and Traceable before it can break the pipeline.
Flow & Commands
03 / How the Flow Executes
04 / Commands
$ git checkout -b feature/login
$ git add -A && git commit -m "feat(auth): add login validation"
$ git push -u origin feature/login
# then open the PR — CI trigger fires automatically
# .github/workflows trigger: CI on every PR + push to main
on:
pull_request:
push:
branches: [main]
Models & Discipline
05 / Branching Models
| Model | Rule | Best for |
|---|---|---|
| GitHub Flow | Branch → PR → main → deploy | CD teams (this series' default) |
| Git Flow | develop + release/* + hotfix/* | Versioned releases |
| Trunk-Based | Tiny branches, merge daily | High-velocity CI |
06 / Failure Modes & Best Practices
- Long-lived branches → merge hell; fix with trunk-based discipline.
- Red checks ignored; fix with required status checks.
- Merge-queue races; fix with merge queues, linear history.
"Merging equals deploying" is false. Merging makes a change a candidate; Continuous Delivery decides deployment.
Check & Handoff
07 / Interview Check
Human review (design) + automated checks (correctness) + merge policy (green + approved = mergeable).
Push, pull request, schedule, manual dispatch, tag/release.
08 / Handoff
The trigger fires — now something must execute. This workflow continues in Pipelines, Build, Test & Artifacts, where the triggered pipeline runs build, test, and scan.
Integration
Picking up from Source Control, where the PR gate was built — CI is the discipline that makes the gate meaningful: integrate daily, verify automatically, fix immediately.
01 / The Three Habits
Integration pain grows with branch age: two-day branches merge in minutes, two-month branches in weeks.
Gates
02 / PR Gates & Merge Queues
- PR gate — required checks + approvals in branch protection. No green, no merge. No admin overrides.
- Merge queue — serializes merges on busy main: rebase onto latest green, re-verify, land. Kills the green-on-branch-red-on-main race.
- Linear history — rebase/squash keeps main bisectable: any commit builds and reverts cleanly.
03 / Trunk Discipline
- Long branches → merge hell (WIP limits + flags).
- Red main normalized → quality collapse (stop-the-line culture).
- Flaky gates → bypassed checks (quarantine flakes, never disable gates).
Discipline (merge small, verify, fix first) vs machinery (the pipeline that enforces it).
Handoff
04 / Handoff
Small merges, verified automatically, fixed immediately — that discipline feeds every pipeline downstream. Continue in Pipelines, Build, Test & Artifacts.
📇 Quick Revision — Terms Table
| Pipeline | The automated workflow from commit to production. |
| Stage | A logical phase: build, test, scan, deploy. |
| Job | A unit of executable work inside a stage. |
| Step | A single operation inside a job. |
| Runner | The machine executing jobs; agent in Jenkins. |
| Artifact | Versioned build output: image, JAR, binary. |
| Digest | Content hash pinning the exact artifact (sha-9f3a). |
| Registry | Storage and distribution for artifacts. |
| Promotion | Approving the same artifact for the next environment. |
| Gate / Check | A required verification before proceeding. |
| Merge queue | Serializes merges onto latest green main. |
| Trunk-based | Tiny branches merged daily; flags hide unfinished work. |
| Branch | An independent line of work forked from main. |
| Pull request | Merge proposal coupling human review with CI checks. |
| Trigger | The event starting a pipeline: push, PR, schedule, manual. |
| Staging | Prod-like rehearsal; deploys automatic. |
| Production | Real users; deploys gated or automated. |
| Approval | The human or policy decision releasing to production. |
| Continuous Delivery | Every change releasable; deployment is a decision. |
| Continuous Deployment | Every passing change ships by itself. |
🎤 Concept Questions — Distilled Answers
Delivery keeps software production-ready behind an approval; Deployment releases validated changes automatically.
Otherwise you tested one binary and shipped another — verification is void.
Human review for design plus automated checks for correctness plus merge policy: green and approved equals mergeable.
Push, pull request, schedule, manual dispatch, tag or release.
Discipline — merge small, verify, fix first — versus machinery: the pipeline that enforces it.
Long-lived divergent branches; trunk-based discipline with tiny daily merges and flags.
Not necessarily — it means only the checks inside that pipeline passed.
Trunk: branch to PR to main to deploy, for CD teams. Git Flow: develop plus release branches, for versioned releases.
STAR story: red main on a Friday deploy — stopped the line, reverted first, then landed a required check so the class of breakage can never merge again.
📌 Command Cheat Sheet
git checkout -b feat/x | short branch, merge daily |
git push -u origin feat/x | publish + trigger CI |
gh pr create --fill | PR with CI gate |
docker build -t registry/app:SHA . | versioned image |
docker push registry/app:SHA | same digest everywhere |
🧪 Self-Quiz + Answer Key
- Does this change work?
- Source, build, test, artifact, release, deploy.
- An immutable digest stored versioned in a registry.
- Mergeable.
- The green-on-branch-red-on-main race.
- Long branches.
- Whoever broke it — first, before anything else.
- Delivery: releasable behind a decision. Deployment: shipped automatically.