Intermediate · CI/CD pipelines · topic 25 of 53 · 25 min
Continuous integration, delivery and deployment
Explanation
The problem CI solves
Picture five developers who each work on their own branch for three weeks. On merge day nothing fits together: the same files were changed in different ways, tests fail, and nobody knows whose change broke what. Teams used to call this "integration hell". Another old problem is "it works on my machine": code passes on one laptop but fails everywhere else because of a different setup.
Continuous integration (CI) fixes both. Developers merge small changes into the shared main branch often, at least daily. Every push triggers an automated build and test run on a clean machine, so problems show up within minutes, while the change is small and fresh in the author's mind. The team's first rule: keep main green (passing). If a build breaks, fixing or reverting it comes before any new work.
Delivery versus deployment
The letters CD have two meanings, and people mix them up:
| Continuous delivery | Continuous deployment | |
|---|---|---|
| What happens to a passing change | It is ready to release at any time | It goes to production automatically |
| Who presses the button | A person approves the production release | Nobody; the pipeline does it |
| Good fit | Banks, regulated apps, scheduled releases | Web apps with strong tests and monitoring |
Both need the same foundation: automated tests you trust, and a pipeline that deploys the same way every time.
The stages of a pipeline
A pipeline is the series of automated steps a change goes through. A stage is one group of steps with a clear job. A typical web app pipeline looks like this:
- Checkout: fetch the exact commit that was pushed.
- Install: download dependencies from the lock file (npm ci, pip install -r requirements.txt).
- Lint: check style and catch simple bugs without running the code.
- Test: run unit tests, then integration tests.
- Build: compile or bundle the app, or build the container image.
- Scan: check dependencies and the image for known vulnerabilities, and the code for leaked secrets.
- Package and publish: push the artefact (a versioned image or package) to a registry.
- Deploy to staging: a production-like environment, then run smoke tests (a few quick checks that the main pages and APIs work).
- Approval: a person or an automatic check agrees to release.
- Deploy to production: then watch the dashboards.
push → checkout → install → lint → test → build → scan → publish
↓
production ← approval ← staging + smoke testsPrinciples that make pipelines work
- Fail fast: run the cheapest, quickest checks first (lint, unit tests) so most mistakes are caught in a couple of minutes, and stop at the first failure.
- Pipeline as code: the pipeline definition is a file in the repository (a workflow YAML or a Jenkinsfile), reviewed in pull requests and versioned with the code.
- Build once, deploy many: build the artefact one time, then promote that same artefact through staging and production. Only configuration changes between environments.
- Fast feedback: aim for a pipeline that tells a developer the result in about ten minutes. Slow pipelines get ignored.
- Everything automated: a manual step in the middle is where mistakes and delays creep in.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Continuous integration, delivery and deployment · 1/7
In this lesson you will learn what continuous integration, continuous delivery and continuous deployment mean, and what a pipeline does.
Prefer a video by a teacher? Find free videos on “continuous integration continuous delivery vs continuous deployment explained” on YouTube ↗
In real life: A Pune fintech moves from monthly releases to daily ones
A 15-person fintech team in Pune used to release once a month after a weekend of manual testing, and each release broke something. They set up CI: every pull request runs lint and 1,200 unit tests in 6 minutes, and main must stay green. The pipeline builds one container image per merge, tags it with the git SHA, deploys it to staging and runs smoke tests on the loan application flow. Because they are regulated, they chose continuous delivery: a release manager approves production deploys with one click. They now release several times a week, and each release is small enough to understand and roll back.
Practice (0/3 done)
Every change that passes the pipeline goes to production with no human approval. What is this called?
Simulate a pipeline runner. runPipeline(stages) gets stages in run order; each is { name, needs: [names], ok: true or false } where ok says whether the stage itself would pass. A stage is "skipped" if any stage it needs did not end as "success". Otherwise it is "success" if ok is true, or "failed" if ok is false. Return an object mapping each stage name to its status, in the same order. You can assume every needed stage appears earlier in the list.
Design a CI/CD pipeline for a college placement portal (a Node.js API plus a React frontend, deployed as a container to a Kubernetes cluster). List the stages in order, say what each does, which ones run on pull requests and which only on main, and where the approval goes.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- GitHub ActionsCI/CD pipelines · same module
- Jenkins pipelinesCI/CD pipelines · same module
- Testing, quality gates and artefactsCI/CD pipelines · same module
- CI/CD: shipping every change safelyFull-Stack Development · Deploying and running the app
- Integration testing: checking parts work togetherBackend Development · Testing and API documentation
- Integration tests and CIFlutter and Dart · Responsive design and testing
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
What is the main idea of continuous integration?
Answer: Merge small changes often, and build and test every push automatically
Frequent small merges with automated checks catch problems while they are small.
What does "build once, deploy many" mean?
Answer: Build the artefact one time and promote the same one through staging and production
Shipping the exact artefact you tested removes "it worked in staging" surprises.
Which order follows the fail-fast idea?
Answer: Lint and unit tests, then slower integration tests, then deploy
Cheap, quick checks first give feedback in minutes and save the slow stages for changes that are already likely good.
What does "pipeline as code" mean?
Answer: The pipeline definition is a file in the repository, reviewed and versioned with the code
A workflow YAML or a Jenkinsfile in the repo gives history, review and easy copying between projects.
Why use npm ci instead of npm install in a pipeline?Related
Answer: It installs exactly the versions in package-lock.json, giving repeatable builds
npm ci does a clean install from the lock file, so CI uses the same versions every time.
What does an integration test check that a unit test does not?Related
Answer: That several parts, like handler and database, work together
Integration tests check the joins between parts, where many real bugs live.
Out of 20 production deployments, 3 caused an incident. What is the change failure rate?Related
Which binding must integration tests initialise?Related
Answer: IntegrationTestWidgetsFlutterBinding
Call ensureInitialized() first.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 4 more topics in “CI/CD pipelines” before its exam: GitHub Actions, Jenkins pipelines, Testing, quality gates and artefacts, Deployment strategies, feature flags and GitOps.
- Module 6 exam: CI/CD pipelines · 12 questions · 20 min, without help. 5 topics of this module still to finish first.
- Then the next module, Infrastructure as code with Terraform. 53 topics left in the course before the final exam.