A CI/CD pipeline is the automated path a code change follows from a developer's commit to running in production. Done well, it turns releases from a stressful, scheduled event into something the team does many times a week without thinking twice. Done badly, it becomes a slow, flaky gate that everyone tries to bypass.
This guide covers the stages of a good pipeline, how the popular tools differ, the main deployment strategies and the practices that keep a pipeline fast and trustworthy. It is the practical core of most DevOps consulting engagements, and it builds on the ideas in What Is DevOps?.
CI, continuous delivery and continuous deployment
The three terms are related but not interchangeable:
- Continuous integration (CI): developers merge small changes into the main branch often, and every change is verified by an automated build and test run.
- Continuous delivery: every change that passes the pipeline is in a releasable state. Releasing to production is a button press, often behind a human approval.
- Continuous deployment: every change that passes goes to production automatically, with no manual gate.
Most small and mid-size teams should aim for continuous delivery first. Continuous deployment is excellent when you have strong automated tests, gradual rollouts and good monitoring; without those, a manual approval is a sensible safety net.
The stages of a CI/CD pipeline
- 01Commit
A push or pull request triggers the pipeline. Linting and formatting checks give feedback in seconds.
- 02Build
Install dependencies from a lockfile and compile or bundle the application in a clean environment.
- 03Test
Fast unit tests first, then integration and API tests. Stop at the first failing stage.
- 04Security scan
Check dependencies for known vulnerabilities, detect committed secrets, run static analysis and scan container images.
- 05Artifact
Produce one versioned, immutable package or container image and store it in a registry.
- 06Deploy
Promote that same artifact to staging, then production, using infrastructure and configuration defined as code.
- 07Verify
Run smoke tests and health checks, watch error rates and latency, and roll back automatically if they degrade.
Two principles hold the stages together. First, build once, deploy many: the artifact tested in staging must be byte-for-byte the one that reaches production, with environment differences supplied as configuration. Second, fail fast: order the stages so the cheapest checks run first, and aim for pull-request feedback in minutes rather than hours. Slow suites such as full end-to-end or performance tests can run after merge or on a schedule instead of blocking every change.
The test stage is only as good as the tests behind it. If you are deciding what to automate, our guide to manual vs automation testing explains how to choose, and our software testing and QA team can help build a suite worth trusting.
Choosing a CI/CD tool
The three tools most teams shortlist are GitHub Actions, GitLab CI/CD and Jenkins. All three can run a professional pipeline; the right choice depends mostly on where your code lives and how much infrastructure you want to manage.
| GitHub Actions | GitLab CI/CD | Jenkins | |
|---|---|---|---|
| Hosting | GitHub-hosted or self-hosted runners | GitLab.com or self-managed, hosted or own runners | Self-hosted only |
| Configuration | YAML workflows in the repository | A .gitlab-ci.yml file in the repository | Jenkinsfile (Groovy-based pipeline as code) |
| Strengths | Tight GitHub integration, large marketplace of reusable actions | One platform for code, CI, registry and issues | Very flexible, huge plugin ecosystem, works fully offline |
| Best fit | Teams already on GitHub | Teams wanting an all-in-one platform or self-hosting | Complex or on-premise builds, existing Jenkins estates |
| Watch out for | Third-party actions are code you run: pin their versions | Some features depend on the plan tier | You maintain the server, plugins and security patches |
Other credible options include Azure Pipelines for teams invested in Microsoft tooling, plus CircleCI and Bitbucket Pipelines. Whichever you pick, keep the pipeline definition in the repository so it is reviewed like any other code. If deployments must reach servers inside a private network, plan for self-hosted runners or agents there, and treat those machines as sensitive infrastructure.
Deployment strategies
How you release matters as much as how you build. The three common strategies differ in cost, complexity and how many users a bad release can reach.
- Replace instances in batches
- No extra infrastructure needed
- Old and new versions run side by side briefly
- Rollback means rolling forward again
- Run a full copy of the new version alongside the old
- Switch traffic in one step once checks pass
- Near-instant rollback by switching back
- Needs double capacity during the release
- Send a small share of traffic to the new version first
- Widen gradually while metrics stay healthy
- Needs good monitoring and traffic control
- Best for high-traffic, high-risk services
verdictStart with rolling deployments plus a tested rollback; add blue-green or canary for services where a bad release is expensive.
Feature flags complement all three. They separate deploying code from releasing a feature, so unfinished work can ship switched off and a problem can be disabled without a redeploy. Treat flags as temporary and remove them once a feature is fully live, or they become technical debt of their own.
A minimal first pipeline for a small team
You do not need every stage on day one. A first version that runs on every pull request and every merge to main already removes most release anxiety:
- Lint, build and run unit tests on every pull request, and block merging when they fail.
- Scan dependencies and check for committed secrets in the same run.
- On merge, build one versioned artifact or container image and push it to a registry.
- Deploy that artifact to staging automatically and run a short smoke test against it.
- Promote the same artifact to production with a single approval, and keep a documented, rehearsed rollback.
Once that is stable, add integration tests, gradual rollouts and post-deploy checks one at a time. Each addition should answer a real problem you have seen, such as a bug that reached production or a deployment that failed halfway.
The hard part: database changes
Application rollbacks are easy; database rollbacks are not. The safe pattern is expand and contract: first deploy a migration that only adds (a new column or table), then deploy code that writes to both the old and new structure, migrate the data, switch reads, and only remove the old structure in a later release. Every step stays compatible with the previous version of the code, so rolling back the application never breaks the database.
Best practices that keep pipelines healthy
- Cache dependencies between runs
- Run independent test suites in parallel
- Move slow suites to post-merge or nightly runs
- Protect the main branch and require passing checks
- Keep migrations backward compatible
- Test the rollback path, not just the deploy
- Keep secrets in the CI secret store or a vault, never in the repository
- Prefer short-lived cloud credentials (OIDC) over long-lived keys
- Pin third-party actions and plugins to exact versions
- Review pipeline changes like application code
- Quarantine flaky tests with an owner and a deadline
- Send failures to the team channel, not one inbox
How to know the pipeline is working
Measure the pipeline as a product. Track how long pull-request checks take, how often they fail for reasons unrelated to the change, and the four delivery measures covered in our DORA metrics guide. If lead time is long, look for queues: waiting for review, waiting for a test environment, waiting for a release window. If change failure rate is high, invest in tests and gradual rollouts before trying to deploy more often.
Watch for warning signs too: developers re-running failed jobs until they pass, long-lived branches that are painful to merge, manual steps written in a wiki next to the pipeline, or a release that only one person knows how to run. Each of these points at a specific fix, whether that is quarantining flaky tests, smaller pull requests or automating the remaining manual step.
Pipelines also depend on the environments they deploy to. Defining those with infrastructure as code means staging really does match production, and our cloud consulting work often starts there. The same pipeline patterns apply whether you ship a Node.js API, a .NET service or a mobile app.
DivTech designs and builds CI/CD pipelines for teams that want reliable, boring releases. If yours is slow, flaky or still partly manual, get a quote for a pipeline review and we will suggest where to start.
Frequently asked questions
What is the difference between CI and CD?
CI (continuous integration) automatically builds and tests every change merged into the main branch. CD means either continuous delivery, where every passing change is ready to release with a manual approval, or continuous deployment, where it is released automatically.
Which CI/CD tool should a small team choose?
Usually the one built into the platform where your code already lives: GitHub Actions for GitHub, GitLab CI/CD for GitLab. Jenkins makes sense when you need full control on your own infrastructure and have someone to maintain it.
How long should a CI pipeline take?
Pull-request checks should give feedback in minutes so developers stay in flow. Many teams treat ten minutes as a practical ceiling and move slower suites to post-merge or scheduled runs.
Is blue-green or canary deployment better?
Neither is better in general. Blue-green gives a simple, near-instant switch and rollback at the cost of double capacity during a release. Canary limits how many users see a bad release but needs good monitoring and traffic routing.