Skip to content

Intermediate · CI/CD pipelines · topic 25 of 53 · 25 min

Continuous integration, delivery and deployment

Explanation

Continuous integration (CI) means everyone merges small changes into the main branch often, and every push is built and tested automatically. Continuous delivery keeps every passing change ready to release with one approval; continuous deployment releases it to production automatically. A pipeline is the series of automated stages, from checkout and tests to building an artefact and deploying it.

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 deliveryContinuous deployment
What happens to a passing changeIt is ready to release at any timeIt goes to production automatically
Who presses the buttonA person approves the production releaseNobody; the pipeline does it
Good fitBanks, regulated apps, scheduled releasesWeb 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:

  1. Checkout: fetch the exact commit that was pushed.
  2. Install: download dependencies from the lock file (npm ci, pip install -r requirements.txt).
  3. Lint: check style and catch simple bugs without running the code.
  4. Test: run unit tests, then integration tests.
  5. Build: compile or bundle the app, or build the container image.
  6. Scan: check dependencies and the image for known vulnerabilities, and the code for leaked secrets.
  7. Package and publish: push the artefact (a versioned image or package) to a registry.
  8. Deploy to staging: a production-like environment, then run smoke tests (a few quick checks that the main pages and APIs work).
  9. Approval: a person or an automatic check agrees to release.
  10. Deploy to production: then watch the dashboards.
output
push → checkout → install → lint → test → build → scan → publish
                                                        ↓
                         production ← approval ← staging + smoke tests
The usual flow. Any failed stage stops everything after it.

Principles 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.
Think of it like this: A pipeline is like the quality checks on a car assembly line. Each station checks one thing, and a car with a bad weld never reaches the paint shop. The cheapest checks happen first, and the same car that passed all checks is the one delivered, not a fresh copy built for the customer.
Careful: Common mistakes. (1) Rebuilding the app separately for staging and production: what you tested is not what you ship. Build once and promote. (2) Long-lived feature branches that only meet CI at merge time: merge small changes often, hiding unfinished work behind feature flags. (3) Getting used to red builds ("it is just that flaky test"): soon nobody trusts the pipeline. (4) Printing secrets in pipeline logs. (5) A manual "copy the files to the server" step in the middle of an automated pipeline.

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

CI/CD

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)

Task 1 · Question

Every change that passes the pipeline goes to production with no human approval. What is this called?

Task 2 · Code · Javascript

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.

Task 3 · Practice

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

Question 1

1.What is the main idea of continuous integration?

Question 2

2.What does "build once, deploy many" mean?

Question 3

3.Which order follows the fail-fast idea?

Question 4

4.What does "pipeline as code" mean?

Read more (free)

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.

From CI/CD: shipping every change safely

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.

From Integration testing: checking parts work together

Out of 20 production deployments, 3 caused an incident. What is the change failure rate?Related

Answer: 15%

3 / 20 = 0.15, which is 15%.

From Core DevOps practices and the DORA metrics

Which binding must integration tests initialise?Related

Answer: IntegrationTestWidgetsFlutterBinding

Call ensureInitialized() first.

From Integration tests and CI

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

  1. 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.
  2. Module 6 exam: CI/CD pipelines · 12 questions · 20 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, Infrastructure as code with Terraform. 53 topics left in the course before the final exam.

← Previous: Helm and Kustomize