CI/CD pipeline best practices: fast feedback, safe releases and the metrics that matter
By AKINO Labs · Updated
The short answer
A good CI/CD pipeline merges small changes to the main branch at least daily, builds and tests every commit in about ten minutes, deploys the same artefact through every environment, keeps secrets out of code, releases gradually with a quick way back, and is measured with DORA's delivery metrics such as lead time, deployment frequency and change fail rate.
Key takeaways
- DORA's guidance sets an upper limit of about ten minutes for builds and tests, and says a broken build is fixed or reverted before other work.
- Trunk-based development means short-lived branches merged to main at least daily, with three or fewer active branches.
- Build once and promote the same artefact through every environment.
- Release gradually behind feature flags or canaries, and make rollback a routine, tested step.
- Measure delivery with DORA's metrics, which balance throughput against instability.
What is a CI/CD pipeline?
A CI/CD pipeline is the automated path a code change takes from a developer's commit to running in production. Continuous integration merges and tests every change; continuous delivery keeps the result always ready to release; continuous deployment releases every passing change automatically.
A typical deployment pipeline has these stages:
- Commit. Compile, lint, run unit tests and static security checks on every push.
- Build. Produce one versioned artefact, such as a container image, and store it.
- Test. Integration, contract and acceptance tests against a production-like environment.
- Release. Deploy the same artefact to staging and then production, gradually.
- Verify. Watch error rates and latency after each release, and roll back automatically if they breach a threshold.
The point is not the tooling. It is that every change goes through the same steps, so releasing becomes routine rather than an event.
How fast should a CI pipeline give feedback?
Fast enough that developers wait for it rather than moving on. DORA's continuous integration guidance says each commit should trigger a build and tests that give feedback in a few minutes, cites its research for an upper limit of about ten minutes, and says longer acceptance and performance feedback should arrive within a day.
Ways to keep the commit stage fast:
- Run tests in parallel and cache dependencies between runs.
- Move slow end-to-end and performance tests to a later stage, so they do not block every commit.
- Delete or fix flaky tests promptly. A test that fails at random teaches people to ignore failures.
- Build only what changed, where the tooling supports it.
When the build breaks, fixing it comes before any other work. DORA's guidance is that if it cannot be fixed within a few minutes, the change that broke it should be identified and reverted.
What is trunk-based development and why does it matter?
Trunk-based development is a branching approach where developers merge small batches of work into the main branch at least once a day, instead of keeping feature branches open for days or weeks.
DORA's capability guide describes branches that typically last no more than a few hours, three or fewer active branches in the repository, and no code freezes or separate integration phases. It also recommends making code review synchronous and part of development.
Two practices make this workable:
- Feature flags. Unfinished work is merged but switched off, so main is always releasable.
- Small pull requests. A change reviewed in minutes merges the same day; one reviewed over a week conflicts with everything else.
Long-lived branches defer integration, and integration problems grow with the time between merges. Merging daily keeps them small.
Trunk-based development depends on the pipeline. If tests are slow or unreliable, developers batch their changes to avoid waiting, branches grow, and the benefits disappear. Fix the feedback loop before mandating the branching model.
How should you handle environments, infrastructure as code and secrets?
Define every environment in code, keep them as alike as possible, build the artefact once, and never store secrets in the repository.
- Build once, promote many times. The artefact tested in staging is the one released to production. Rebuilding per environment means production runs something nobody tested.
- Infrastructure as code. Networks, databases, queues and permissions defined in version-controlled files and applied by the pipeline, so changes are reviewed and repeatable. See infrastructure as code.
- Environment parity. Same operating system, runtime versions and configuration shape; differences only in size and data.
- Configuration outside the artefact. Settings injected per environment, not baked into the build.
- Secrets in a secrets manager. Fetched at run time, scoped to the service that needs them, rotated on a schedule, and scanned for in every commit.
- Least privilege for the pipeline. The pipeline can deploy to production, so its credentials are among the most sensitive you hold.
How do you release safely with progressive delivery and rollback?
Release to a small share of users first, watch the signals that matter, widen the release only when they look healthy, and keep rollback fast enough to use without a meeting.
Progressive delivery techniques
- Canary releases. A new version serves a small share of traffic while error rates and latency are compared with the current version.
- Blue-green deployments. Two production environments; traffic switches from one to the other and can switch back.
- Feature flags. Code is deployed dark and enabled for internal users, then a segment, then everyone.
Rollback
- Make redeploying the previous artefact a single, tested pipeline action.
- Design database changes to be backward compatible: add columns before using them, and remove old ones only in a later release.
- Automate the decision where you can, with thresholds that trigger rollback without waiting for a person.
How do you measure CI/CD performance with DORA metrics?
Measure the pipeline with DORA's software delivery metrics, which pair how fast changes flow with how often they cause problems. Many teams know them as the four keys. DORA's current metrics guide lists five, adding deployment rework rate.
Track them per service and look at trends, not single values. Throughput rising while instability also rises means speed is being bought with incidents.
Collect them from the systems that already record the events: version control for commits, the pipeline for deployments, and the incident tool for failures and recoveries. Hand-reported figures drift quickly. Use the metrics to find where the delivery process is slow, not to rank teams against each other, which encourages gaming the numbers.
| Metric | What it measures | Group |
|---|---|---|
| Change lead time | Time from a change being committed to it being deployed to production | Throughput |
| Deployment frequency | How often deployments happen, or the time between them | Throughput |
| Failed deployment recovery time | How long it takes to recover from a deployment that needs immediate intervention | Throughput |
| Change fail rate | Share of deployments that need immediate intervention, such as a rollback or hotfix | Instability |
| Deployment rework rate | Share of deployments that are unplanned and result from a production incident | Instability |
What are the most common CI/CD pipeline mistakes?
The most common mistakes are pipelines that are too slow to trust, tests that fail at random, and manual steps that turn a routine release back into an event.
- Treating a red build as normal. Once a failing pipeline is ignored for a day, every later failure is ignored too, and the pipeline stops protecting anything.
- Manual gates for every change. An approval meeting before each release adds waiting without adding much safety. Reserve human approval for changes that genuinely warrant it, and let automated checks cover the rest.
- Different builds per environment. Rebuilding for production means the code that reaches users was never tested in that form.
- Infrastructure changed by hand. A console change that is not in code is lost the next time the environment is recreated, and drift between staging and production follows.
- Security checks bolted on at the end. Dependency, container and secret scanning belong in the commit stage, where a finding costs minutes to fix, not in a review the week before launch.
- Database changes released with the code that needs them. Separate the schema change from the code change, so either can be rolled back alone.
- No owner. Pipelines are software. Give them an owning team, version control and their own monitoring.
For older systems with little test coverage, start by recording what the system does today in automated tests, then add pipeline stages around them. Our guide to legacy application modernisation covers how to change such systems safely.
How AKINO Labs approaches CI/CD
AKINO Labs builds delivery platforms so shipping is routine rather than an event. Our cloud infrastructure practice covers platform engineering, infrastructure as code, CI/CD, observability and environment parity, alongside landing zones and the reliability work that keeps an uptime target written down and measured.
When the pipeline is slow because the application is hard to change, our software development and modernisation practice adds the test coverage and handover that let your own engineers keep shipping. Our guide to cloud migration strategy covers moving the platform itself.
To look at your own pipeline, book an engineering discovery session.
Where AKINO Labs applies this
- Engineering practiceCloud Infrastructure and DevOpsCloud architecture, migration, platform engineering and cost control for workloads that have to stay up.
- Engineering practiceSoftware Development and ModernisationProduct engineering, legacy modernisation and integration work that leaves you with software your team can maintain.
Questions people ask
What is the difference between continuous delivery and continuous deployment?
Continuous delivery keeps every change that passes the pipeline ready to release, with a person choosing when. Continuous deployment releases every passing change to production automatically.
What are the DORA metrics?
DORA's software delivery metrics are change lead time, deployment frequency, failed deployment recovery time and change fail rate, often called the four keys. DORA's current guide adds a fifth, deployment rework rate.
How long should a CI build take?
DORA's guidance cites an upper limit of about ten minutes for the build and tests that run on each commit. Slower tests belong in a later stage so they do not block every change.
Is trunk-based development suitable for large teams?
Yes, with feature flags, small pull requests and a fast pipeline. DORA describes it as merging to the main branch at least daily with three or fewer active branches, whatever the team size.
Where should secrets live in a CI/CD pipeline?
In a secrets manager, fetched at run time and scoped to the service that needs them, never in the repository or the build artefact. Scan every commit for secrets that slip through.
Sources
- DORA's software delivery performance metrics. DORA. Lists five delivery metrics: change lead time, deployment frequency and failed deployment recovery time for throughput, and change fail rate and deployment rework rate for instability.
- Capabilities: continuous integration. DORA. Says builds and tests should give feedback in a few minutes with an upper limit of about ten minutes, and that a broken build not fixed within minutes should be reverted.
- Capabilities: trunk-based development. DORA. Describes merging to trunk at least daily, branches lasting a few hours, three or fewer active branches, no code freezes and synchronous code review.
Want this worked through on your own operation?
Send one sentence on what you are trying to fix. A practitioner replies with a straight view of what to build, what to buy and what to leave alone.
- A reply from a practitioner, not a sales script.
- A prioritised view of what to build, what to buy, and what to leave alone.
- No obligation. If we are not the right fit, we will say so.