The short answer
Quick answer: A CI/CD pipeline is an automated sequence of steps that runs every time code changes. Continuous integration (CI) means developers merge small changes into a shared branch frequently, and each merge is automatically built and tested, so problems are found within minutes. Continuous delivery (CD) extends this so that every change which passes the tests is packaged and ready to release at the push of a button. Continuous deployment goes one step further and releases it to production automatically. The result is that shipping software becomes a routine, low-risk event that happens many times a day, in place of a rare and stressful one.
The problem it replaced
Teams used to work on separate branches for weeks, then spend days in "integration hell" trying to make everyone's changes work together. Releases were manual: someone followed a long checklist, copied files to servers, and hoped. Releases were infrequent, large and frightening.
The insight behind CI/CD: if something is painful, do it more often. Small, frequent changes are easy to test, easy to review, and easy to fix when they break. Automation makes that frequency possible.
Continuous integration
Martin Fowler's article on Continuous Integration set out the practice. The essentials:
- Everyone merges to the main branch at least daily, using short-lived branches.
- Every change triggers an automated build and test run.
- A broken build is fixed immediately; it is the team's top priority.
- The build is fast, so feedback arrives within minutes.
A typical CI run:
- Check out the code. Version control is the foundation; see how Git stores your code history.
- Install dependencies.
- Lint and format checks.
- Compile or build.
- Run unit tests.
- Run static analysis and security scans.
- Report the result on the pull request.
If any step fails, the change does not merge.
Delivery and deployment
| What is automated | Release to production | |
|---|---|---|
| Continuous integration | Build and test on every change | Not covered |
| Continuous delivery | Everything up to a release-ready, tested artifact | A person presses the button |
| Continuous deployment | Everything | Automatic, if all checks pass |
Continuous delivery keeps the software always releasable. Continuous deployment removes the last manual step. Many organisations choose delivery with a manual approval for business or regulatory reasons.
Anatomy of a pipeline
A pipeline is a set of stages, each containing jobs. Stages usually run in order; jobs within a stage run in parallel.
| Stage | What happens |
|---|---|
| Source | A commit or pull request triggers the pipeline |
| Build | Compile the code; build a container image |
| Test | Unit, integration and end-to-end tests |
| Scan | Dependency vulnerabilities, secrets, licence checks |
| Package | Publish a versioned artifact to a registry |
| Deploy to staging | Release to a production-like environment |
| Verify | Smoke tests and automated acceptance tests |
| Deploy to production | A gradual rollout, possibly after approval |
| Monitor | Watch metrics; roll back if they degrade |
Pipelines are defined in a file stored alongside the code, so changes to the pipeline are reviewed like any other change. A simplified GitHub Actions example:
name: ci
on:
pull_request:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run lint
- run: npm test
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build -t registry.example.com/web:${{ github.sha }} .
The moving parts
- Triggers. A push, a pull request, a tag, a schedule or a manual start.
- Runners (agents). The machines that execute jobs. Each job typically runs in a fresh, isolated environment, usually a container or virtual machine, so runs do not affect each other.
- Artifacts. The outputs: a compiled binary, a package, a container image. They are versioned and stored in a registry.
- Caching. Dependencies and build outputs are reused between runs to save time.
- Secrets. Credentials are injected at run time from a secure store, never committed to the repository.
- Environments. Development, staging and production, with rules about who and what can deploy to each.
Popular tools include GitHub Actions, GitLab CI, Jenkins, CircleCI and Buildkite for pipelines, and Argo CD and Flux for deploying to Kubernetes.
Build once, deploy many times
A core principle: build the artifact once and promote that exact artifact through every environment. What reaches production is byte-for-byte what was tested in staging. Differences between environments come only from configuration supplied at deploy time.
Rebuilding for each environment risks subtle differences and invalidates the testing.
Tests in the pipeline
Tests are arranged so the fastest give feedback first:
| Type | Scope | Speed | How many |
|---|---|---|---|
| Unit | One function or class | Milliseconds | Many |
| Integration | Several components together, such as code plus a database | Seconds | Some |
| End-to-end | The whole system through its interface | Minutes | Few |
This is the test pyramid. A pipeline that relies mostly on slow end-to-end tests is slow and unreliable. Flaky tests, which fail randomly, are especially damaging: people learn to ignore failures.
Deploying safely
Releasing to everyone at once is risky. Pipelines use techniques that limit the blast radius:
- Rolling updates replace instances a few at a time.
- Blue-green deployments switch traffic between two complete environments.
- Canary releases send a small share of traffic to the new version first.
- Feature flags separate deploying code from releasing a feature: the code ships switched off and is turned on later, for some users or all.
- Automated rollback when error rates or latency worsen.
See blue-green and canary deployments. Database changes need extra care: make them backwards-compatible so the old and new versions of the code can both run during the rollout.
Measuring how well it works
The DORA research programme identified four measures that characterise software delivery performance:
| Metric | What it measures |
|---|---|
| Deployment frequency | How often you release to production |
| Lead time for changes | Time from commit to running in production |
| Change failure rate | The share of deployments that cause a problem |
| Time to restore service | How quickly you recover from a failure |
The notable finding is that speed and stability go together. Teams that deploy often, in small changes, also have fewer failures and recover faster.
Securing the pipeline
A pipeline has powerful credentials and can deploy to production, which makes it a target.
- Give pipeline credentials the minimum permissions, and prefer short-lived ones.
- Pin third-party actions and dependencies to specific versions.
- Scan dependencies and images for known vulnerabilities.
- Be careful running pipelines on code from untrusted contributors.
- Sign artifacts and record where they came from.
- Protect the main branch: require reviews and passing checks.
Practices that keep it healthy
- Keep the main branch releasable at all times.
- Keep the pipeline fast. Aim for feedback in about ten minutes. Run jobs in parallel and cache aggressively.
- Fail fast: run the quickest checks first.
- Make changes small.
- Treat a red pipeline as urgent.
- Define infrastructure in code too, so environments are reproducible; see infrastructure as code.
- Make rollback easy and practised.
Frequently asked questions
What does CI/CD stand for?
Continuous integration and continuous delivery (or continuous deployment).
What is the difference between continuous delivery and continuous deployment?
In continuous delivery, every passing change is ready to release, but a person decides when. In continuous deployment, every passing change is released automatically.
What is a pipeline runner?
A machine or container that executes the pipeline's jobs, usually in a clean environment for each run.
How long should a CI pipeline take?
Short enough that developers wait for it. Around ten minutes is a common target for the main feedback loop.
Conclusion
A CI/CD pipeline turns "getting code to production" into an automated, repeatable process: every change is built, tested, packaged and released the same way. The technology is straightforward. The discipline is what matters: small changes, fast feedback, an always-releasable main branch, and gradual rollouts that can be reversed.
Related articles
- How Git Stores Your Code History
- How Blue-Green and Canary Deployments Reduce Risk
- How Docker Containers Work (and How They Differ From VMs)
- Infrastructure as Code: Why Clicking Around in Consoles Doesn't Scale
