Build pipeline

On this page 7

A build pipeline is an automated, ordered sequence of stages that takes source code from a version control commit and turns it into a tested, versioned artifact, such as a binary, package or container image, ready to be deployed. In DevOps, the build pipeline is the executable core of continuous integration: it applies the same steps to every change, so that quality and packaging no longer depend on an individual developer’s machine.

The pipeline is defined as code, usually in a configuration file stored next to the application, and is executed by a CI server or hosted runner. Its output feeds the delivery or deployment pipeline, which promotes the artifact through environments. The guiding principle is build once, deploy many: the same artifact moves from testing to production without being rebuilt.

How a build pipeline works

A pipeline is triggered by an event, most often a push or a pull request, but also by a schedule or a manual start. The CI system checks out the exact commit, provisions a clean environment, typically a container or a fresh virtual machine, and runs the defined stages in order. Each stage contains jobs, and jobs within a stage can run in parallel to save time.

A failing step stops the pipeline and marks the commit as broken. This fail-fast behavior is intentional: problems are reported to the author within minutes, while the change is still fresh, instead of surfacing days later during integration.

StageMain activityTypical duration
Checkout and setupFetch code, restore dependency cacheSeconds to a minute
Static checksLinting, formatting, type checksUnder a few minutes
Compile and packageBuild binaries, bundles or imagesOne to ten minutes
Automated testsUnit and integration testsA few minutes to half an hour
Security scanningDependency and image vulnerability checksOne to several minutes
Publish artifactVersion, sign and store the resultUnder a minute
Typical stages of a build pipeline

Key building blocks and settings

Several mechanisms decide whether a pipeline is fast, reproducible and trustworthy. They are configured in the pipeline definition and the CI platform, and each has a direct effect on developer feedback time.

Building blockWhat it doesWhy it matters
Runner or agentMachine or container that executes jobsDefines speed, isolation and available tools
Dependency cacheReuses downloaded packages between runsCuts minutes from each build
Artifact repositoryStores versioned build outputsEnables build once, deploy many
Secrets storeInjects credentials at run timeKeeps keys out of code and logs
Matrix buildsRuns jobs across versions or platformsCatches compatibility issues
Quality gatesThresholds for tests, coverage or findingsBlocks low-quality changes
Pipeline building blocks and their effect

A widely used target is a feedback time of about ten minutes for the main pipeline. Longer pipelines encourage developers to batch changes and skip waiting for results, which undermines the purpose of continuous integration. Slow suites are often split so that fast checks run on every commit and longer tests run on merge or nightly.

The build pipeline is often used loosely to mean any CI/CD automation. Distinguishing it from neighboring terms clarifies where responsibilities lie and which part of the process a failure belongs to.

TermFocusRelation to the build pipeline
CIFrequent integration with automatic verificationThe build pipeline implements it
CDAutomated release to environmentsConsumes the artifact the pipeline produces
Blue-green deploymentSwitching traffic between two environmentsA release strategy after the build
Canary deploymentGradual release to a small share of usersA release strategy after the build
DevOpsCulture and practices joining development and operationsThe pipeline is one of its core tools
The build pipeline among neighboring DevOps concepts

Designing a dependable pipeline

A dependable build pipeline produces the same result for the same commit, every time and on every runner. Reproducibility requires pinned dependency versions, lock files, pinned base images and tools, and clean environments that do not carry state from previous runs.

ProblemTypical causeRemedy
Flaky testsTiming, shared state, external servicesIsolate tests, quarantine and fix quickly
Slow buildsNo caching, serial jobs, huge test suitesCache, parallelize, split test tiers
Works locally, fails in CIUnpinned tools or hidden local statePin versions, build in containers
Leaked credentialsSecrets printed or stored in codeUse masked secrets and scoped tokens
Rebuilt artifacts per environmentBuilding separately for each stageBuild once and promote by version
Common problems and how to address them
  • Keep the pipeline definition in the same repository as the code it builds.
  • Treat a red main branch as an urgent priority for the whole team.
  • Record the commit, dependencies and build environment with each artifact for traceability and supply chain security.

Limitations and misconceptions

A green pipeline proves only that the defined checks passed. If tests are thin or quality gates are disabled to save time, the pipeline gives a false sense of safety. Its value is limited by the quality of the tests it runs.

The pipeline is also a privileged system. It holds credentials for registries and often for production, so a compromised runner or a malicious dependency can reach far beyond the build. Least-privilege tokens, isolated runners and review of pipeline changes are therefore part of pipeline security, not optional extras.

In everyday language

A build pipeline is like an assembly line in a factory. Raw parts, the code written by developers, enter at one end, and every part passes through the same stations: assembly, inspection and packaging.

If an inspection station finds a defect, the line stops and the problem is sent back right away. What comes out at the end is a finished, labeled product ready to ship. Every change goes through the same checks, so quality no longer depends on someone remembering every step.

Seen in the real world

A team of twelve developers maintains a web application. Before introducing a build pipeline, one engineer built releases on a personal laptop every two weeks, and integration problems routinely took two or three days to sort out before each release.

The team defines a pipeline that runs on every pull request: linting, compilation, about 1,800 unit tests in four parallel jobs, a dependency scan and the creation of a versioned container image. With caching, the run takes about eight minutes. Merges are allowed only when the pipeline is green, and the same image is later promoted to staging and production. Integration problems now appear within minutes of the change that caused them, and the team moves to several releases per week.