CI/CD architecture
Continuous integration (CI) means every change is merged frequently and automatically built and tested. Continuous delivery (CD) means every change that passes is ready to release at the push of a button; continuous deployment goes one step further and releases it automatically. The pipeline that does this is critical architecture: it decides how fast and how safely change reaches users, and it holds the keys to production.
The DORA research program (opens in a new tab) has shown for years that teams which deploy more often, with shorter lead times, also tend to have lower change failure rates and faster recovery. Speed and stability go together when the pipeline is designed well.
Diagram
Section titled “Diagram”- Every commit is built once into a versioned, signed artifact and unit tested in minutes.
- Security scans and policy checks run on the artifact, followed by integration and contract tests.
- The same artifact is released progressively, to a small share of traffic first.
- Production metrics decide whether the rollout continues or rolls back automatically.
Design principles
Section titled “Design principles”- Build once, promote the same artifact. Rebuilding for each environment means production runs something that wasn’t tested. Configuration differs per environment; the artifact doesn’t.
- Fast feedback first. Order stages so the quickest, most likely to fail checks run first. Aim for a commit-stage result in under ten minutes.
- Trunk-based development with small changes and short-lived branches; long-lived branches make integration painful and releases risky.
- Test in layers: unit tests, then contract tests between services, then a small number of end-to-end tests. Many slow end-to-end tests make the pipeline flaky and slow.
- Separate deploy from release. Deploy code dark behind feature flags (opens in a new tab), then release to users gradually.
- Progressive delivery. Canary or blue-green releases with automatic rollback on error-rate or latency regressions. See canary release.
- Databases need care. Use backward-compatible schema changes (expand, migrate, contract) so code and schema can be deployed and rolled back independently.
- Everything as code: pipelines, infrastructure (IaC) and policies, versioned and reviewed.
Securing the pipeline
Section titled “Securing the pipeline”The pipeline can change production, so it’s a prime target for attackers.
- Short-lived credentials for deployments, using workload identity federation rather than stored long-lived keys.
- Least privilege per pipeline and environment; build jobs can’t deploy to production.
- Protected branches and required reviews for anything that reaches production.
- Dependency and image scanning, and pinning of third-party actions and plugins.
- Signed artifacts and provenance, so production runs only what your pipeline built. The SLSA framework (opens in a new tab) describes levels of supply chain assurance.
Measure it
Section titled “Measure it”Track the four DORA metrics: deployment frequency, lead time for changes, change failure rate, and time to restore service. They show whether pipeline changes are helping.
Common pitfalls
Section titled “Common pitfalls”- Manual approval gates as the main safety mechanism, which slow everything and catch little. Automated checks and progressive release catch more.
- Flaky tests that teams learn to rerun until green, hiding real failures.
- Different artifacts per environment.
- A shared pipeline service account with admin rights everywhere.
Related patterns
Section titled “Related patterns”Written and edited by Abhinav Taduka, enterprise software architect.
New pages are added regularly. Follow Abhinav on LinkedIn to see them first.