Cloud & Data Centers

Continuous Integration and Delivery

How pipelines build, test and release code in small steps, with safe ways to roll back.

Key takeaways

  • Continuous integration catches conflicts and bugs early by testing every small change as it arrives.
  • Continuous delivery keeps software releasable, while continuous deployment ships each passing change automatically.
  • Build an artifact once and promote that same artifact through test and production.
  • Gradual rollouts, feature flags and a rehearsed rollback limit the damage from a bad release.
  • Pipelines hold powerful credentials, so treat them as production systems.

Continuous integration means developers merge their changes into a shared codebase often, and each change is automatically built and tested. Continuous delivery goes further: every change that passes is kept ready to release at any time. Continuous deployment releases it to users automatically. The three are usually shortened to CI/CD.

The idea behind all of them is that small, frequent, checked changes are safer than large, rare ones. This article explains what a pipeline does, how releases are made less risky and how to start without building an elaborate system.

Why small and frequent works

Picture two developers working separately for six weeks, then combining their work. Their changes collide in many places, and when something breaks, thousands of lines are suspects.

Now picture each merging a small change every day. Conflicts are caught while the work is fresh. A new failure points at a small set of edits. Releases become routine instead of an event people dread.

This only holds if checks run automatically and the shared branch is kept working. When a build breaks, fixing or reverting it comes before new work.

Three terms, one spectrum

Integration, delivery and deployment
Continuous integration Merge often Build and test every change Keep the main branch working Continuous delivery Every passing build is releasable A person chooses when to ship Deployment is one repeatable step Continuous deployment Passing changes ship automatically No manual release step Needs strong tests and monitoring Continuous integration Merge often Build and test every change Keep the main branch working Continuous delivery Every passing build is releasable A person chooses when to ship Deployment is one repeatable step Continuous deployment Passing changes ship automatically No manual release step Needs strong tests and monitoring

None is a higher grade of virtue. A team shipping a mobile app through store review, or software for a regulated environment, may reasonably keep a manual release decision.

Branching habits

How a team uses branches shapes how well integration works. In trunk-based development, people commit to the main branch directly or through branches that live a day or less. Unfinished features stay hidden behind switches.

The more common pull request style creates a short branch, runs the pipeline on it, gets a review and merges. It works well as long as branches stay short. A branch that lasts for weeks has quietly stopped being integrated, even if a pipeline tests it every day, because it isn't meeting anyone else's changes.

Smaller changes also get better reviews. A reviewer can reason carefully about 50 lines and will mostly trust 2,000. If a feature is large, split it into steps that are each safe to merge. Git basics covers the commands involved.

Anatomy of a pipeline

A pipeline is a series of automated stages triggered by an event, such as a pushed commit or a pull request. Common stages:

  1. Check out the code at that exact version.
  2. Install dependencies, pinned to known versions.
  3. Lint and format check for obvious mistakes.
  4. Build the application.
  5. Test, from fast unit tests to slower end-to-end ones.
  6. Scan for known vulnerable libraries and accidentally committed secrets.
  7. Package an artifact and store it.
  8. Deploy to an environment and verify.

Popular systems include GitHub Actions, GitLab CI/CD and Jenkins. They differ in configuration syntax, but the shape is the same.

From commit to production
1 Commit A small change is pushed. 2 Build One versioned artifact is produced. 3 Test Automated checks must pass. 4 Staging The artifact runs in a production-like copy. 5 Release Rolled out to users in steps. 6 Watch Metrics decide whether to continue. Commit A small change is pushed. 1 Build One versioned artifact is produced. 2 Test Automated checks must pass. 3 Staging The artifact runs in a production-like copy. 4 Release Rolled out to users in steps. 5 Watch Metrics decide whether to continue. 6

A minimal example

This is a small GitHub Actions workflow for a Node.js project. It runs tests on every push and pull request. Action version numbers change over time, so check the current ones.

name: ci
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 24
      - run: npm ci
      - run: npm test

npm ci installs exactly what the lock file lists, which keeps builds repeatable. The file lives in the .github/workflows folder of the repository.

Tests that earn trust

A pipeline is only as good as its checks. Unit tests verify small pieces quickly. Integration tests confirm pieces work together, for instance code against a real database. End-to-end tests drive the application as a user would and catch the most, but they're slow and more fragile.

Many teams keep lots of fast tests and a smaller set of end-to-end ones covering critical paths, such as signing in and paying.

Flaky tests, which fail randomly, are corrosive. People learn to rerun until green and stop believing red. Quarantine them quickly and fix or delete them. Keep the main feedback loop short, because a pipeline that takes an hour invites batching changes together.

Keeping pipelines fast and repeatable

Slow pipelines change behavior: people batch work, skip checks or wander off and lose context. A few habits help. Cache downloaded dependencies between runs. Run independent test groups in parallel. Order stages so the cheapest checks fail first. Run the slowest suites on a schedule or before release if they can't be made quick.

Repeatability matters as much as speed. Run each job in a clean environment, such as a fresh virtual machine or container, so leftovers from the last run can't make a test pass. Pin tool and library versions with lock files. If a build works on one laptop and fails in the pipeline, the pipeline is usually revealing an undeclared dependency.

Keep pipeline definitions in the same repository as the code, so changes to how you build are reviewed and versioned alongside what you build.

Build once, promote the same thing

Produce one artifact, such as a container image or package, give it a unique version, and move that exact item from test to staging to production. Rebuilding for each environment risks pulling a different library and releasing something you never tested.

Differences between environments should live in configuration, not in the build. Secrets come from a protected store at run time. Staging sites explains how to keep a test copy realistic without exposing real customer data.

Releasing with less risk

Several strategies limit how many users a bad change can reach.

  • Rolling release: replace servers a few at a time.
  • Blue-green: run the new version beside the old, then switch traffic, keeping the old ready for a quick return.
  • Canary: send a small share of traffic to the new version, compare error and latency figures, then widen.
  • Feature flags: deploy code switched off, then enable it for chosen users. Remove old flags so they don't pile up.
A canary release loop
Expand Raise the share and measure again. Decide Widen if healthy, roll back if not. Release to a few A small share of traffic gets the new version. Measure Compare errors and speed with the old one. 1 2 3 4 Release to a few A small share of traffic gets the new version. 1 Measure Compare errors and speed with the old one. 2 Decide Widen if healthy, roll back if not. 3 Expand Raise the share and measure again. 4

Good monitoring is what makes these work. Without a signal to compare, a canary is just a slow release. An error budget can help decide how cautious to be.

Rollback and database changes

Know how to return to the previous version before you need to. Redeploying the last good artifact should be one action.

Databases make this harder. If a release renames a column, old code can't run against the new schema. A safer pattern is expand and contract: add the new column, write to both, copy old data, switch reads, and only later remove the old one. Each step works with the version before it.

Some changes, like deleting data, can't be rolled back. Take a backup first and consider delaying the destructive step until the release has proven itself.

Verifying after deployment

A deployment step that finishes without errors only shows the files arrived. Follow it with a smoke test: request key pages, call a health endpoint, run a harmless test transaction and check that the version reported matches the one you shipped.

Then watch error rates and response times for a while. Mark the release time on your dashboards so a later change in behavior is easy to connect to it. Decide in advance what result triggers a rollback, and let whoever notices it act without waiting for a meeting.

Common problems

  • A red build everyone ignores. Agree that fixing the main branch comes first.
  • Manual steps hiding in the middle. A setting changed by hand will be forgotten. Script it.
  • Environments that differ. Staging passes and production fails because versions or settings don't match.
  • Releases bundled for weeks. Large releases make problems hard to isolate and rollbacks costly.
  • No owner. Someone needs to maintain the pipeline, update its tools and prune dead stages.

Securing the pipeline

A pipeline can read your code and often change production, so it's an attractive target. Sensible precautions:

  • Grant each job the minimum permissions it needs.
  • Prefer short-lived, automatically issued credentials to stored long-lived keys.
  • Don't expose secrets to builds triggered by untrusted contributions.
  • Pin third-party actions and dependencies, and review updates.
  • Require review before changes to the pipeline itself.
  • Keep logs of who released what, and make sure secrets aren't printed in them.

Getting started

Begin with continuous integration: run existing tests on every change and block merging when they fail. If there are no tests, start with a build check and a few tests around the parts that break most.

Then script deployment so it's one command, even if a person runs it. Add staging, then automate the release when the checks have earned your confidence. For a simple website, a pipeline that builds the pages and uploads them may be everything you need, as described in deploying a website from laptop to live. Server setup can join the same pipeline through infrastructure as code.

Common questions

Do small teams need this?

Even one developer benefits from automated tests and a repeatable deployment, especially when fixing something late at night.

Does continuous deployment mean less testing?

It requires more automated testing and better monitoring, because no manual step stands between a merge and your users.

How often should we release?

As often as you can do safely and calmly. Frequency is a result of good checks and easy rollback more than a target to chase.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Cloud & Data Centers →

Latest news on this topic