A CI/CD pipeline is an automated path that takes a code change from a developer’s commit to a running application. Every push goes through the same build and test checks, and changes that pass can be released with a click or with no click at all. It is the most widely adopted DevOps practice: in JetBrains’ State of CI/CD 2026 survey, 83.4% of respondents who use DevOps practices run CI/CD pipelines.
This guide explains what a CI/CD pipeline does and how CI differs from the two kinds of CD. It then walks through the seven stages most pipelines share, with a complete working example on GitHub Actions you can adapt for your own project.

The short version
- CI means every change is merged often and checked automatically by a build and tests.
- CD means every change that passes is ready to release (delivery) or released automatically (deployment).
- A typical CI/CD pipeline has seven stages: source, build, test, scan, package, deploy to staging and deploy to production.
- GitHub Actions is the most used tool in 2026, with Jenkins and GitLab CI behind it.
- Measure your pipeline with the DORA metrics: deployment frequency, lead time, change failure rate and time to restore.
- Start small: a pipeline that builds and tests every pull request is already most of the value.
What is a CI/CD pipeline?
A CI/CD pipeline is a series of automated steps that runs every time someone changes the code. It checks out and builds the code, then runs tests and other checks. After that it packages the result and deploys it to one or more environments. When a step fails the pipeline stops there and alerts the team, so broken changes never reach users.
Before CI/CD, teams often merged weeks of work at once and spent days fixing conflicts and bugs before a release. A CI/CD pipeline replaces that with small changes that are checked in minutes. The result is faster releases with fewer surprises.
Why does a CI/CD pipeline matter?
Three reasons come up in almost every team that adopts one:
| Without a pipeline | With a CI/CD pipeline |
|---|---|
| “Works on my machine” bugs | Every change builds in the same clean environment |
| Manual, error-prone releases | Releases follow the same scripted steps every time |
| Bugs found days or weeks later | Tests run within minutes of each push |
| Releases are rare and stressful | Small, frequent releases that are easy to roll back |
CI vs continuous delivery vs continuous deployment
The “CD” in CI/CD means two slightly different things, and the difference matters when you design a CI/CD pipeline.

| Practice | What happens after tests pass | Who presses the button |
|---|---|---|
| Continuous integration (CI) | Change is merged into the main branch | No release yet |
| Continuous delivery | Change is packaged and ready to deploy at any time | A person approves the production release |
| Continuous deployment | Change goes to production automatically | Nobody; the pipeline does it |
Most teams start with CI, add continuous delivery with a manual approval for production, and move to continuous deployment only once their tests and monitoring are trusted.
The 7 stages of a CI/CD pipeline
Most pipelines share the same stages, whatever the tool. Smaller projects merge some of them; larger ones split them further.

Stage 1: Source
The pipeline starts when code changes: a push, a pull request or a merged branch. The trigger decides what runs. Pull requests usually run the checks only, while merges to the main branch also package and deploy.
Stage 2: Build
The build turns source code into something runnable: compiled binaries, a bundled front end or a container image. A good build is repeatable, meaning the same commit always produces the same result. That is why pipelines install exact dependency versions from a lock file.
Stage 3: Test
Automated tests decide whether a change is safe. Most pipelines run fast unit tests first, then slower integration tests that talk to a database or other services. Tests that fail randomly, often called flaky tests, are the biggest threat to trust in a CI/CD pipeline, so fix or quarantine them quickly.
Stage 4: Scan
Security and quality checks look for problems tests miss: vulnerable dependencies and leaked secrets, as well as insecure code patterns and licence problems. Running them in the pipeline means every change is checked, not just the ones someone remembered to review.
Stage 5: Package
The pipeline builds the deployable artifact once and stores it, for example as a container image in a registry or a package in an artifact store. Every later stage deploys this same artifact. Building again for production risks shipping something different from what was tested.
Stage 6: Deploy to staging
The artifact is deployed to a staging or preview environment that looks like production. Smoke tests and end-to-end tests run against it. Some teams create a short-lived preview environment for each pull request.
Stage 7: Deploy to production
The final stage releases the change to users. In continuous delivery, a person approves this step. In continuous deployment, it runs automatically. Safer release methods, such as rolling updates, canary releases or feature flags, limit the damage if something slips through.
A working CI/CD pipeline example with GitHub Actions
Here is a complete CI/CD pipeline for a Node.js web service packaged as a container image. On every pull request it runs the checks. On merges to main it also builds and pushes an image and deploys it to staging. Production waits for an approval.

name: ci-cd
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-24.04
strategy:
matrix:
node: [22, 24]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm run lint
- run: npm test
build-image:
if: github.ref == 'refs/heads/main'
needs: test
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v5
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
deploy-staging:
needs: build-image
runs-on: ubuntu-24.04
environment: staging
steps:
- run: ./deploy.sh staging ghcr.io/${{ github.repository }}:${{ github.sha }}
deploy-production:
needs: deploy-staging
runs-on: ubuntu-24.04
environment: production
steps:
- run: ./deploy.sh production ghcr.io/${{ github.repository }}:${{ github.sha }}
How the example works
| Part | What it does |
|---|---|
on: pull_request and push to main |
Pull requests run tests only; merges run the full pipeline |
permissions: contents: read |
Read-only token by default, raised only for the image push |
| Test matrix on Node 22 and 24 | Checks both supported runtimes in parallel |
needs: |
Each job waits for the previous one, so a failed test stops the release |
| Image tagged with the commit SHA | Staging and production deploy exactly the same artifact |
environment: production |
With required reviewers set, production waits for a human approval |
Set up the production environment in the repository settings with required reviewers, and the last job will pause until someone approves it. That turns this CI/CD pipeline into continuous delivery. Remove the reviewers and it becomes continuous deployment.

The example pins ubuntu-24.04 rather than ubuntu-latest on purpose. GitHub moved ubuntu-latest to Ubuntu 26.04 in November 2026, and explicit labels mean your pipeline only changes when you decide. Our guide to the ubuntu-latest move explains the trade-off.
The same pipeline in GitLab CI
GitLab CI describes the same ideas with stages in a .gitlab-ci.yml file. Jobs in the same stage run in parallel, and each stage starts when the previous one passes.

stages: [test, build, staging, production]
test:
stage: test
image: node:24
script:
- npm ci
- npm test
build:
stage: build
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
rules:
- if: $CI_COMMIT_BRANCH == "main"
deploy_production:
stage: production
script: ./deploy.sh production
when: manual
environment: production
The when: manual line plays the same role as the GitHub environment approval. For a deeper look at how the tools differ, see our comparison of GitHub Actions vs GitLab CI vs Jenkins.
Which CI/CD tools are most popular in 2026?
GitHub Actions leads, with Jenkins still strong in larger organisations. According to JetBrains’ analysis of its developer surveys, the most used tools are:

| Tool | Organisations | Personal projects |
|---|---|---|
| GitHub Actions | 33% | 39% |
| Jenkins | 28% | 13% |
| GitLab CI | 19% | 10% |
About a third of organisations run two CI/CD tools at once, and nearly one in ten run three or more. The same research found that 18% of developers use no CI/CD tool at all, which is a large group still doing releases by hand.
Do CI/CD pipelines run in the cloud or on-premises?
Both, and more on-premises than you might expect. Help Net Security’s summary of JetBrains’ State of CI/CD 2026 reports that 72.8% of respondents run their primary CI/CD system on their own premises or on self-managed cloud infrastructure, the highest on-premises share in the five years JetBrains has asked.
How do you measure a CI/CD pipeline?
Use the four DORA metrics, from Google’s DevOps Research and Assessment programme. They measure the outcomes a CI/CD pipeline is supposed to improve: speed and stability.

| Metric | Question it answers | Measures |
|---|---|---|
| Deployment frequency | How often do we release to production? | Speed |
| Lead time for changes | How long from commit to production? | Speed |
| Change failure rate | What share of releases cause a problem? | Stability |
| Time to restore service | How fast do we recover from a failure? | Stability |
DORA’s research has found for years that the best teams do well on both speed and stability at once. A good pipeline improves all four: small changes deploy often, automated tests catch problems early, and repeatable deployments make rollback quick.
CI/CD pipeline best practices
These practices separate pipelines that teams trust from ones they work around:
| Practice | Why it matters |
|---|---|
| Keep the main branch always releasable | Anyone can ship at any time |
| Aim for checks under 10 minutes | Slow pipelines get skipped or batched |
| Build once, deploy the same artifact everywhere | Production runs exactly what was tested |
| Fix or quarantine flaky tests the same week | Random failures destroy trust |
| Store pipeline config in the repository | Changes are reviewed like code |
| Use least-privilege tokens and short-lived credentials | A compromised job can do less harm |
| Pin tool versions and runner images | Builds do not change under you |
| Make rollback a single, tested command | Recovery is fast when something slips through |
Keep your CI/CD pipeline secure
A CI/CD pipeline holds the keys to production, which makes it a target. In 2026, attackers compromised the popular Trivy scanning action and poisoned more than 5,500 repositories’ workflows in a single day. Set the default token to read-only, pin third-party actions to commit SHAs, and use OIDC instead of long-lived cloud keys. Our guide to GitHub Actions security walks through ten fixes.
CI/CD pipeline triggers explained
A trigger decides when a CI/CD pipeline runs. Choosing the right trigger for each job keeps pipelines fast and avoids wasted runner minutes.
| Trigger | Typical use | Example in GitHub Actions |
|---|---|---|
| Pull request | Run checks before code is merged | on: pull_request |
| Push to main | Package and deploy merged changes | on: push with branches: [main] |
| Tag | Build and publish a versioned release | on: push with tags: ["v*"] |
| Schedule | Nightly long test suites or dependency scans | on: schedule with a cron expression |
| Manual | Deploys or maintenance tasks run on demand | on: workflow_dispatch |
One trigger needs special care. GitHub’s pull_request_target runs fork pull requests with repository secrets, and GitHub blocks it by default in public repositories from 2 December 2026. Our pull_request_target guide explains the safer alternatives.
What does a CI/CD pipeline look like for different projects?
The seven stages adapt to almost any kind of project. The names change, but the idea of checking every change automatically stays the same.
| Project type | Build output | Key tests | Deploy target |
|---|---|---|---|
| Web application | Container image or static bundle | Unit, API and browser tests | Kubernetes, a PaaS or a CDN |
| Mobile app | Signed app bundle | Unit tests and device or emulator tests | App store testing tracks, then the store |
| Library or package | Versioned package | Unit tests across supported versions | npm, PyPI, Maven Central or similar |
| Infrastructure as code | Terraform or OpenTofu plan | Format, validate and policy checks | Cloud accounts, after plan review |
| Data pipeline | Container or job definition | Data quality and schema tests | A scheduler such as Airflow |
For infrastructure, the “test” stage is often a plan that a person reviews before it is applied. For libraries, the “deploy” stage is publishing a release. Our article on AWS billing alerts shows a budget defined as code, which fits neatly into an infrastructure pipeline.
How much does a CI/CD pipeline cost?
For most small projects, nothing. GitHub Actions is free for public repositories on standard runners, and GitHub’s plans include a monthly allowance of minutes for private repositories. GitLab’s free tier also includes a monthly allowance of compute minutes. Costs start when you need more minutes, larger machines or extra features.
GitHub changed its Actions pricing for 2026. According to GitHub, prices for GitHub-hosted runners dropped by up to 39% on 1 January 2026. A planned $0.002 per minute platform charge for self-hosted runners was postponed while GitHub re-evaluates it, and GitHub said 96% of customers would see no change to their bill.
Ways to keep CI/CD pipeline costs down:
- Cache dependencies so each run does not download them again.
- Cancel outdated runs when a new commit arrives on the same branch.
- Run slow test suites on merges or on a schedule instead of every push.
- Use smaller runners for light jobs such as linting.
How is AI changing CI/CD pipelines?
AI is entering pipelines, but mostly around them rather than inside them. According to JetBrains’ State of CI/CD 2026, 48.8% of organisations use AI for at least one CI/CD-related task, such as code review, writing or fixing tests, or diagnosing failed builds. Only 8% run AI-powered steps directly inside a build or test.
Teams using AI also report a new problem: the volume of AI-generated changes slows code review and makes reliability harder to judge. A fast, trusted CI/CD pipeline becomes more important, not less, when more changes arrive faster.
Common CI/CD pipeline mistakes
| Mistake | What to do instead |
|---|---|
| Building a huge pipeline on day one | Start with build and test on pull requests, then add stages |
| Running every test on every change | Run fast tests first; run slow suites on merge or nightly |
| Deploying a fresh build to production | Promote the tested artifact through environments |
| Storing secrets in the pipeline file | Use the platform’s secrets store or OIDC |
| Ignoring a red main branch | Treat a broken main as the team’s top priority |
| No way to roll back | Keep previous artifacts and a one-step rollback |
How do I start building my first CI/CD pipeline?
Start with the smallest useful pipeline and grow it. A practical path for a new project:
- Add a workflow that installs dependencies and runs tests on every pull request.
- Add linting and a dependency vulnerability scan to the same workflow.
- Protect the main branch so pull requests cannot merge with failing checks.
- Build and store an artifact, such as a container image, on merges to main.
- Deploy that artifact to a staging environment automatically.
- Add a production deployment that waits for approval.
- Track deployment frequency and lead time from your pipeline history.
Steps 1 to 3 take an afternoon and deliver most of the value. The rest can follow as the project grows.
CI/CD pipeline glossary
New terms are one of the hardest parts of learning CI/CD. These are the ones you will see most often in pipeline files and documentation:
| Term | Meaning |
|---|---|
| Runner or agent | The machine that executes pipeline jobs, hosted by the provider or by you |
| Job | A set of steps that run on one runner |
| Stage | A group of jobs that run together before the next group starts |
| Artifact | A file produced by a job, such as a build or test report, passed to later jobs |
| Environment | A named deploy target, such as staging or production, often with its own secrets and approvals |
| Matrix | Running the same job across several versions or operating systems in parallel |
| Cache | Saved dependencies reused between runs to save time |
| Secret | A credential stored by the CI system and injected into jobs at run time |
| Rollback | Returning production to the previous working version |
| Canary release | Sending a small share of traffic to a new version before everyone gets it |
Once these words are familiar, pipeline files in any tool become much easier to read, because most tools only rename the same ideas.
Frequently asked questions
What is a CI/CD pipeline in simple words?
It is an automated assembly line for software. Every code change goes through the same automated build and test steps, and changes that pass can be released quickly and safely.
What is the difference between CI and CD?
CI (continuous integration) merges and tests every change automatically. CD (continuous delivery or deployment) takes changes that pass CI and makes them ready to release, or releases them automatically.
What are the stages of a CI/CD pipeline?
Most pipelines have seven: source, build, test, scan, package, deploy to staging and deploy to production. Small projects often combine some of them.
Which tool is best for a CI/CD pipeline?
GitHub Actions is the most used and the easiest start for code already on GitHub. GitLab CI suits teams on GitLab, and Jenkins suits organisations that need full control of a self-hosted system.
Is a CI/CD pipeline only for large teams?
No. A solo developer benefits from automated tests and repeatable deployments just as much, and free tiers of GitHub Actions and GitLab CI cover most small projects.
How long should a CI/CD pipeline take?
Aim for pull request checks under about 10 minutes. Longer pipelines encourage people to batch changes, which brings back the problems CI/CD is meant to solve.
What are DORA metrics?
Four measures of software delivery: deployment frequency, lead time for changes, change failure rate and time to restore service. They show whether a pipeline is making releases both faster and safer.
Can I run a CI/CD pipeline on my own server?
Yes. Jenkins is built for self-hosting, and both GitHub Actions and GitLab CI support self-hosted runners that execute jobs on your machines while the pipeline is defined in the repository. Self-hosting gives you control over hardware and network access, but you take on patching and security for those machines.
Do I need Docker for a CI/CD pipeline?
No, but containers make builds and deployments more consistent, which is why many pipelines package applications as container images.
Build the small version this week
A CI/CD pipeline does not need to be perfect to be useful. A workflow that tests every pull request and protects the main branch already removes the most painful release problems. Add packaging and staging one stage at a time, then approvals. Keep the pipeline fast and secure. Measure it with the DORA metrics so you know it is working.


