Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 44 ยท CI/CD Fundamentals

What Is CI/CD?

Learn what CI/CD means, how continuous integration, delivery and deployment differ, what a pipeline does, and what it costs and saves your team.

Imagine five developers who each work on their own copy of a project for three weeks. On the last day they try to combine everything. Two people changed the same function, one renamed a file that another still imports, and a third upgraded a library that breaks the first person's code. Nobody knows which change caused which failure, and the release slips by a week. This is the problem that CI/CD exists to remove.

CI/CD is a set of habits plus the automation that supports them. Continuous integration means merging small changes into a shared branch many times a day and checking each one automatically. Continuous delivery and continuous deployment extend that idea all the way to production. In this lesson you will learn the three terms precisely, the stages of a typical pipeline, and the real costs of the approach. The rest of this track shows how to build such pipelines with GitHub Actions, Jenkins and GitLab.

The tools named in this track (GitHub Actions, Jenkins, GitLab) need accounts, servers or runners, so they cannot run inside this website. Their commands and configuration appear in read-only code blocks. Each lesson also has runnable stand-ins: small programs that model how the idea works, so you can see the logic with your own eyes. The text always says which part is real and which part is the stand-in.

The pain that CI solves

The longer two lines of work stay apart, the harder they are to merge. There are two reasons:

  1. Conflicts grow quickly. If each developer holds n unmerged changes, the number of pairs of changes that might interact is n ร— (n โˆ’ 1) / 2. Ten changes give 45 possible interactions; forty give 780.
  2. Failures become hard to trace. When a build breaks after one small change, the culprit is obvious. When it breaks after a month of work from five people, you have to search.

Continuous integration answers with a simple rule: integrate often, and verify every integration automatically. A server builds the project and runs the tests on every push. If something breaks, the team learns within minutes, while the change is still fresh in the author's mind.

Run the next stand-in to see the arithmetic. It is not a model of any particular tool, only the counting argument behind CI.

JS Why small, frequent integrations win

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Even with a smart search (bisection halves the suspects each time), the growth in possible interactions is what makes big merges painful. Pairs grow with the square of the batch size.

CI, continuous delivery and continuous deployment

The abbreviation CD hides two different ideas, so be precise about which one you mean.

Term What is automated Who presses the final button
Continuous integration (CI) Build and test every change merged to the shared branch Nobody: it runs on every push
Continuous delivery CI plus packaging and deployment to test environments; the result is always ready to release A person decides when to release
Continuous deployment Everything above plus automatic release to production Nobody: every change that passes goes live

Continuous delivery keeps a human decision at the end, often for business reasons (a marketing date, a regulated industry). Continuous deployment removes that decision, and so it demands very good tests and a fast way to roll back. Many teams practise continuous delivery for most services and continuous deployment for a few low-risk ones.

flowchart LR
    A["Commit"] --> B["Build"]
    B --> C["Test"]
    C --> D["Package"]
    D --> E["Deploy to staging"]
    E --> F{"Release decision"}
    F -->|"Manual approval"| G["Production (delivery)"]
    F -->|"Automatic"| H["Production (deployment)"]

The same pipeline serves both models. The only difference is whether a person or a rule releases to production.

The stages of a typical pipeline

A pipeline is the automated path a change takes from a commit to a running system. The exact stages differ between projects, but most look like this:

  1. Checkout. Fetch the exact revision of the code that triggered the run.
  2. Build. Compile the code or install dependencies. A failure here means the change does not even assemble.
  3. Static checks. Linters, formatters and type checkers: cheap, fast and quick to fail.
  4. Test. Unit tests first, then slower integration and end-to-end tests.
  5. Package. Produce something deployable: a binary, an archive, a container image.
  6. Publish or deploy. Push the package to a registry, deploy it to staging, and finally to production.

The order is deliberate. Cheap stages come first so that failures are reported as soon as possible, and later stages are skipped when an earlier one fails. This is called failing fast, and it saves both time and compute.

The next stand-in is a tiny pipeline engine. Each stage is a function that returns whether it passed. The engine runs them in order and stops at the first failure, which is exactly how real tools treat a failed job.

JS A pipeline that stops at the first failure

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Change B never reaches the package stage, so a broken build can never be released by accident. That guarantee is the core value of a pipeline.

What it buys you, and what it costs

CI/CD is not free, and an honest account of both sides helps you decide how much to invest.

Benefits

  • Fast feedback. Problems appear minutes after the change, not weeks.
  • A releasable main branch. The shared branch always builds and passes its tests.
  • Repeatable releases. The same scripted steps run every time, so releases stop depending on one person's memory.
  • Smaller, safer changes. Small releases are easier to review and easier to undo.
  • Less manual work. Machines do the repetitive checks and humans review design.

Costs

  • Setup and maintenance. Pipelines are code that must be written, reviewed and kept up to date.
  • Test quality matters. Automation only reports what your tests can see. Flaky or missing tests make the pipeline noisy or misleading.
  • Compute and waiting time. Slow pipelines hurt productivity. Making them fast is a recurring task (see Making Pipelines Fast).
  • Cultural change. Teams must keep the main branch green, merge in small pieces and treat a red build as urgent.

A pipeline is a tool for a team habit. A team that ignores red builds gets no benefit from even the best automation.

Where Git and containers fit

CI/CD builds on a version control system. Every pipeline starts with a commit, a push or a pull request, so a good grasp of branches and pull requests helps (see Git branches and pull requests). Many pipelines also build container images; if you are new to those, read Docker basics first. For a first look at hosted automation, Git and GitHub Actions gives a short introduction that this track expands.

The three pillars

CI/CD works because three habits support each other. Remove one and the other two wobble.

  • Automation. Builds, tests, packaging and deployment are scripts, not checklists. A script does the same thing at 3 a.m. as at 3 p.m.
  • Fast, visible feedback. Every change gets a verdict within minutes, and everybody can see it. A red pipeline is a team problem, not a private one.
  • Small, frequent changes. The smaller the change, the easier it is to review, to test and to undo. Pipelines make small changes cheap, and small changes keep pipelines fast.

Acceptance testing and the release decision

Between "the unit tests pass" and "customers can use it" sits acceptance testing: checking that the product does what the business asked for, in an environment that looks like production. In a delivery pipeline it usually runs against the staging deployment, after the fast tests, and often includes end-to-end browser or API checks. When acceptance tests are automated, "ready to release" becomes a fact the pipeline reports instead of a meeting. The result is the release candidate: one artifact that passed every stage and is the exact thing you would ship. Delivery and deployment differ only in what happens to that candidate next.

Why adoption is hard

Most teams that struggle with CD do not struggle with the tools. The usual obstacles are:

  • Testing bottlenecks. A slow or flaky test suite makes people ignore the pipeline. Fix this first: split tests by speed, run the quick ones early, and quarantine flaky ones (see Pipeline performance and Test stages).
  • Manual gates that nobody owns. A sign-off step that waits days defeats the point. Keep a human approval only where a real decision is needed.
  • Resistance to change. Developers worry about breaking production more often; operations worry about being paged. Start with one service, show the numbers (lead time, failure rate, time to recover) and let results persuade.
  • Fragile environments. If staging differs from production, passing there proves little. Describe environments as code.
  • Large batches. Teams used to sprint-end releases tend to bundle weeks of work. Shrink the batch gradually: weekly, then daily, then per merge.

A common path is to begin with CI only, add automated deployment to a test environment, then add production deployment behind an approval, and finally remove the approval once the tests and the rollback have earned trust.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the central rule of continuous integration?

    CI is about integrating frequently and checking every integration with an automated build and tests, so problems show up while the change is still small.
  2. 2. A pipeline deploys to staging automatically, but a manager must approve the production release. Which practice is this?

    In continuous delivery the software is always ready to release, and a person chooses when. Continuous deployment removes that human decision.
  3. 3. Why do pipelines usually run linting and unit tests before slower end-to-end tests?

    Putting fast, cheap stages first gives quick feedback and skips expensive stages when an earlier one has already failed.
  4. 4. Which statement about the cost of CI/CD is accurate?

    A pipeline can only report what the tests check. Poor tests reduce its value, and the pipeline itself is code that needs upkeep.

Summary

  • CI/CD removes the pain of late, large merges by integrating small changes often and checking each one automatically.
  • Continuous integration builds and tests every change; continuous delivery keeps the result always releasable with a human release decision; continuous deployment releases every passing change automatically.
  • A pipeline is an ordered series of stages (checkout, build, checks, test, package, deploy) that fails fast and skips later stages after a failure.
  • Benefits are fast feedback, repeatable releases and a healthy main branch; costs are setup, maintenance, compute time and the team discipline to keep builds green.
  • Automation is only as good as the tests behind it.

Next: Anatomy of a Pipeline