Topic guide

CI/CD automation: how a change gets from commit to production

CI/CD automation turns the hand-run path from commit to release into a pipeline: a fixed series of stages that builds, tests, deploys and checks every change the same way. This guide takes that pipeline apart stage by stage.

What are the stages of a CI/CD pipeline?

Martin Fowler describes a deployment pipeline as a build broken up into stages, each adding confidence, usually at the cost of extra time. Whatever your tools call them, the notes say what a green result at each stage guarantees.

Continuous integration

On every push to mainline, in minutes

  1. 1

    Commit

    The change is small, on mainline, and everything needed to build it is in version control.

  2. 2

    Build

    One command turns the commit into one versioned artifact. No later stage rebuilds it.

  3. 3

    Fast tests

    Unit tests and static checks pass within minutes. A failure is fixed before other work.

Continuous delivery

The rest of the pipeline, to a release-ready build

  1. 4

    Acceptance

    Slower suites pass in parallel in a production-like environment, on the same artifact.

  2. 5

    Staging

    The production deploy script has just worked here, so the deployment itself is tested.

  3. 6

    Approval

    The approval your policy needs happens inside the run, on the record. Continuous deployment automates it.

  4. 7

    Production

    The same artifact is live, and checks after deploy confirm it is healthy.

The way back

If those checks fail, the pipeline redeploys the last good artifact without rebuilding it. The fix or revert then starts again at commit.

  • Each stage adds confidence and takes longer
  • A manual gate
  • The way back
Illustration: a delivery pipeline from commit to verified production, what a green result at each stage guarantees, and the way back.

How do continuous integration, delivery and deployment differ?

The three terms describe how far the automation reaches, and each builds on the one before. DORA notes that continuous delivery is commonly conflated with continuous deployment, but they are separate practices.

Continuous integration, continuous delivery and continuous deployment compared
PracticeWhat it meansHow far automation reachesWho decides to release
Continuous integration Everyone merges to mainline at least daily, and an automated build with tests verifies each merge (Fowler). A tested build on mainline. CI on long-lived feature branches is, in Fowler's words, not continuous integration. Out of scope: it ends before deployment.
Continuous delivery Software that can be released to production at any time (Fowler). DORA calls it the ability to release changes on demand, quickly, safely and sustainably. Everything up to production. Releasing is one push of a button. A person or a policy, at the approval gate.
Continuous deployment Every change that passes the automated stages goes to production on its own (Fowler). All the way. Automated checks replace the approval gate. The pipeline. It requires continuous delivery first.

Which one should a team aim for?

For most teams, continuous delivery: the business picks the moment, and any day can be a release day. Continuous deployment is a choice on top of it. Either way, DORA warns that deploying more often without improving processes and architecture is likely to lead to higher failure rates and burned-out teams.

What does a CI/CD pipeline look like as code?

In Jenkins, the pipeline is a Jenkinsfile in the project's repository. The Jenkins documentation lists what that gives you: a pipeline for every branch and pull request, code review on the pipeline, an audit trail and a single source of truth.

Here is the pipeline above, shortened. The letters match the notes.

Jenkinsfile

pipeline {
  agent none
  options { disableConcurrentBuilds() }
  stages {
    stage('Before production') {
      agent any
      stages {
        stage('Build') {
          steps { sh './build.sh --publish' }
        }
        stage('Fast tests') {
          options { timeout(time: 10, unit: 'MINUTES') }
          steps { sh './test.sh unit' }
        }
        stage('Acceptance') {
          parallel {
            stage('API') { steps { sh './test.sh api' } }
            stage('UI')  { steps { sh './test.sh ui' } }
          }
        }
        stage('Staging') {
          when { branch 'main' }
          steps {
            sh './deploy.sh staging'
            sh './smoke-test.sh staging'
          }
        }
      }
    }
    stage('Production') {
      agent any
      when {
        beforeInput true
        branch 'main'
      }
      input {
        message 'Deploy to production?'
        submitter 'release-approvers'
      }
      steps {
        sh './deploy.sh production'
        sh './smoke-test.sh production'
      }
      post {
        failure { sh './deploy.sh production --previous' }
      }
    }
  }
}
Illustration: a shortened declarative Jenkinsfile for a multibranch job, following the Pipeline syntax reference. The scripts stand in for your own commands.
  1. With no agent at the top level, a release waiting for approval holds no executor. Runs of one branch never overlap.

  2. Build once and publish the artifact. Later stages deploy it and never rebuild.

  3. The commit stage gets a ten-minute budget. A slower run is stopped, so slow tests cannot hide.

  4. Suites run side by side: the stage takes as long as the longest one, not the sum.

  5. Staging runs the production deploy script, then the smoke tests.

  6. beforeInput checks the branch before asking, so feature branches never wait. Only the named group can approve. Without the approval block, this is continuous deployment.

  7. The way back: if the production deploy or smoke tests fail, the stage redeploys the previous version.

What should you automate first?

Work in the order the stages depend on each other, so each step makes the next one cheaper.

  1. Make the build one command

    If a build needs a particular person or machine, nothing after it can be automated. Put everything it needs in version control, the pipeline included.

    Stages: CommitBuild

  2. Run the fast tests on every push

    Trigger the build and tests on every push to mainline. DORA puts the upper limit for that feedback at about ten minutes.

    Stages: Fast tests

  3. Write the deploy down, then script it

    DORA's first step for deployment automation is documenting the existing process. Then script it once and use it for every environment, production included.

    Stages: StagingProduction

  4. Check every deploy and automate the way back

    Checks after deploy and a rollback rehearsed in staging turn a bad release into a short one.

    Stages: ProductionWay back

  5. Move approvals into the pipeline

    DORA found that heavyweight external change approval slows delivery, with no evidence that it lowers change fail rates. Keep the approval your policy needs, inside the run.

    Stages: Approval

  6. Then make it faster

    Parallel suites, production-like test environments, progressive delivery and, where the business wants it, continuous deployment.

    Stages: AcceptanceAll stages

Choosing between two candidates? Count each one's manual steps and waiting time, as DORA suggests, and start with the one that runs most often.

What does CI automation look like in a real engagement?

At ASML, continuous integration for the Stage Position Measurement domain ran in proprietary test environments and was slowed down by manual integration steps. Engineers ran repeatable steps by hand and had no single place to judge release readiness.

The work touched three parts of the pipeline, as the map shows. The ASML case has the details.

What carries over: when tests need scarce hardware, the stages after the build set the pace. That is where shared flows, more test capacity and one readiness view pay off.

300+engineering hours a year saved by removing manual integration steps

Where the ASML work sat in the pipeline above

Stages 1 to 3Commit to fast tests
Self-service CI pipelines in Jenkins, written in Groovy, with automation scripts in Python and Bash, on Linux with Git and ClearCase.
Stage 4Acceptance
CI flows standardized for multiple teams across proprietary test environments. Selected production machine tests started moving to Google Cloud Platform, to raise throughput and shorten feedback cycles.
Stage 6Approval
One Python and SQL reporting view of production machine test results, so the release readiness decision has one place to look.

How do you measure a CI/CD pipeline?

Start with DORA's software delivery performance metrics. DORA now uses five, in two groups. Take them per application or service, read them together, and use them to improve a service over time, not to rank teams.

Throughput

Change lead time
The time from a change being committed to version control to it running in production.
Read it from commit and deploy timestamps in the pipeline's history.
Deployment frequency
The number of deployments in a period, or the time between them.
Read it from the runs that reach production.
Failed deployment recovery time
The time to recover from a deployment that fails and needs immediate intervention.
Read it from the failed deploy to the end of the way back.

Instability

Change fail rate
The share of deployments that need immediate intervention afterwards.
Read it from production runs followed by a rollback or a hotfix.
Deployment rework rate
The share of deployments that are unplanned and caused by an incident in production.
Read it from deploys linked to an incident ticket.

Below the five

DORA's capability pages also suggest measuring the pipeline itself:

  • The share of commits that trigger a build and tests without a manual step
  • The time from a broken build to its fix or revert
  • The manual steps in a deployment, and the time spent waiting between stages
  • The time changes spend waiting for approval

Two warnings from DORA: a metric that becomes a target gets gamed, and one metric on its own misleads. Our article on the four key metrics goes further.

What goes wrong in CI/CD pipelines, and how do you fix it?

Pipeline trouble usually shows up far from its cause. Start from what the team notices.

Common pipeline symptoms, their likely causes and fixes
What the team noticesLikely causeFix
Builds take most of an hour, so people batch changesEvery test runs in one serial stageSplit out a commit stage that answers within ten minutes, and run slower suites in parallel after it.
Rerunning until green is normalFlaky tests are toleratedQuarantine and fix them. DORA's bar: a test failure always indicates a real defect.
Green in staging, broken in productionDifferent artifacts or deploy steps per environmentBuild once. Promote that artifact with the same deploy process everywhere.
Mainline stays red for daysNobody owns a broken buildFix or revert at once. Fowler quotes Kent Beck: nobody has a higher priority task than fixing the build.
Every merge is a small projectLong-lived feature branchesMerge to mainline at least daily, with three or fewer active branches, as trunk-based development asks.
Rollback means a meetingThe way back was never automatedScript the redeploy of the last good artifact and rehearse it in staging.
Only one person can change the pipelineJob settings live in a UI, not in the repositoryKeep the pipeline as code and train the team on it. At Nike, the other platform engineers were trained on the tooling so the knowledge did not sit with one person.

Further reading

Your own pipeline

Where does your release lose its time?

The free Release Check shows what releases cost a year across your applications and where they wait, in under 5 minutes and without a call.