CI CD Pipeline Example: A Step-by-Step Walkthrough
On Monday, a change passes review. By Tuesday, staging is broken, and nobody can name the commit running there. The developer says the tests passed, operations has a successful deployment job, and neither record tells you whether the deployed image is the one anyone tested.
A useful CI/CD pipeline example needs to answer more than how to build and deploy. It needs to show what evidence permits a release, which failures stop it, and what happens when production health deteriorates.
What a CI CD Pipeline Does
A CI/CD pipeline is the automated path a software change takes from commit to production. Each stage produces evidence that determines whether the change can proceed. A successful job without a traceable output isn't enough.
Continuous integration means merging small changes into a shared system frequently, with automated checks that expose incompatibilities early. The continuous integration overview describes this practice as an approach to detecting integration problems through frequent integration and verification, rather than leaving them until project completion.
Continuous delivery and continuous deployment extend that foundation, but they aren't interchangeable:
- Continuous delivery keeps a validated artifact ready for release, while allowing a person to authorize production exposure.
- Continuous deployment automates that final production decision when the required checks pass.
- Continuous integration supplies the build and test feedback that makes either release approach credible.
The distinction matters when designing approval gates. A healthcare service can automate validation and staging without automatically releasing every accepted change. Galliot's explanation of continuous delivery versus continuous integration provides additional context for choosing that boundary.
In the Monday-to-Tuesday scenario, the missing component isn't another deployment tool. It's a chain connecting the reviewed commit, tested artifact, target environment, and release decision.
Practical rule: Treat every promotion as a decision supported by evidence, not simply the next successful command.
The pipeline reduces integration risk through frequent, verifiable changes. That makes CI/CD an engineering discipline, not a collection of deployment tools.
A Working Pipeline Example, Stage by Stage
Take a containerised API backed by PostgreSQL. Its release workflow should hand a specific artifact or record from each stage to the next, with downstream jobs blocked when required evidence is missing.
Pipeline stages, what each runs and the evidence it produces
| Stage | What runs | Output the next stage needs |
|---|---|---|
| 1. Commit | Push to a protected branch with required peer review | Pull request with approval recorded |
| 2. Fast checks | Compile, lint and unit tests run in parallel | Pass/fail report keyed to the commit SHA |
| 3. Build | Build one immutable artifact from the commit | Artifact tagged with the commit SHA |
| 4. Scan | Source, dependency, container-image and infrastructure-configuration scans | Scan report with severity counts |
| 5. Integration and contract tests | API tests against database and service containers | Test report with contract results |
| 6. Publish | Push image to registry, generate SBOM, sign the image | Signed image digest and SBOM |
| 7. Staging deploy | Deploy the same digest to a disposable environment, run smoke tests | Health check and smoke test results |
| 8. Regression and policy checks | Regression suite and policy checks against the staging digest | Policy pass record tied to the digest |
| 9. Production promote | Canary or progressive rollout of the same digest with an automatic rollback threshold | Promotion record with approver and digest |
NIST's guidance on CI/CD software-supply-chain security frames protection across source, build, packaging, and deployment activities. Implement that protection throughout the workflow, not as an isolated security job at the end.

Establish the candidate
Commit with review. Protect the main branch and require peer approval before merging. Record the exact merged SHA so checks can't accidentally authorize a different revision.
Run fast checks concurrently where they're independent. Linting and unit tests shouldn't wait for each other, although tests requiring compiled outputs must wait for compilation.
Build the container once, using pinned dependencies and a controlled builder. Tag it with the commit SHA, but use its content-addressed digest as the deployment identity.
Scan the source, dependency graph, image, and Terraform configuration. Tools such as Semgrep, Trivy, and Checkov can cover different surfaces, but their reports must feed an explicit blocking policy rather than merely appear in job logs.
Validate and promote
Integration and contract tests should exercise the built API against real database and service containers. This catches issues such as incompatible schemas and response formats that isolated unit tests won't expose.
Publish the candidate to the release registry with its software bill of materials, or SBOM, and image signature. Earlier container-based jobs can consume the saved image artifact; publishing shouldn't rebuild it.
Deploy that digest into a disposable staging environment using short-lived credentials. Run smoke tests immediately so a broken startup or unreachable database stops further validation.
At the promotion gate, execute regression suites and policy checks against the staging digest. Reserve expensive end-to-end checks for this gate instead of delaying every developer feedback cycle.
Finally, promote the same digest through a canary or progressive rollout. For practical endpoint and user-journey coverage, CheckMyApp's guidance on post-deploy checks on live apps is a useful companion to infrastructure health signals.
Never rebuild between staging and production. A rebuild can resolve different dependencies or use a changed base image, so the released binary may differ from the tested binary. Every stage should leave a record someone can audit later.
Failure Rules That Decide What Gets Promoted
A test fails, then passes when rerun. Should the release proceed? A green-path diagram can't answer that question, and an unlimited retry button only makes the evidence less trustworthy.
The Thoughtworks overview of the 2025 DORA report describes AI as an amplifier of existing engineering strengths and weaknesses, emphasizing small batches and thorough testing. Faster code production doesn't remove the need to decide which failures are acceptable.
Failure outcomes for common pipeline failures
| Failure | Blocks promotion? | Response | Example |
|---|---|---|---|
| Unit test fails | Yes | Stop the build and notify the author | Null-check regression in the order service |
| Flaky test passes on rerun | No, once formally quarantined | Rerun twice, log the failure, retain nightly execution with an owner and deadline | Timing-dependent assertion |
| High-severity dependency finding | Yes, unless an approved exception exists | Fail the scan; upgrade or waive with a documented expiry date | Vulnerable logging library |
| Smoke test fails in staging | Yes | Stop promotion and retain staging for debugging | API starts but can't connect to PostgreSQL |
| Canary error rate exceeds threshold | Stop promotion and roll back | Automatically restore the previous compatible digest | New order requests fail while the control remains healthy |
| Database migration fails | Pause | Assess state, roll forward with a fix, or require approval; no automatic rollback | Irreversible column drop |
Quarantine isn't deletion
For this example, configure two diagnostic reruns as the retry limit, not as repeated opportunities to turn a red job green. Preserve the original failure, rerun outcomes, logs, and affected commit.
Quarantine only after an engineer establishes that the failure is intermittent rather than a reproducible regression. Keep the test in the nightly run, assign an owner and repair deadline, and require another reliable check for any release-critical behavior it covered. A failing safety-critical check shouldn't become non-blocking merely because it's inconvenient.
Match recovery to reversibility
A unit-test failure blocks because it contradicts expected behavior before deployment. A staging smoke failure also blocks, but retaining that environment gives the author somewhere to inspect configuration, startup logs, and database connectivity.
A dependency exception needs an approver, justification, compensating control, and expiry date. After expiry, the pipeline should block again automatically. A permanent waiver is an undocumented change to your security policy.
Canary rollback is appropriate only when the previous application version remains compatible with current data and configuration. Dropping a database column breaks that assumption: redeploying the old image won't restore the column or its contents.
Decide failure outcomes before the incident, encode them in pipeline configuration, and review them after each failed release.
For schema changes, prefer expand-and-contract migrations. Introduce compatible structures, migrate usage, and remove obsolete structures only after older application versions no longer require them.
Adding Model, Data and Audit Gates for Regulated Systems
A green application build doesn't establish that a model-serving release is safe. The deployed behavior depends on code, model weights, datasets, feature transformations, prompts, and configuration together.
The 2025 DORA report found that 90% of respondents use AI at work, while reporting an ongoing negative relationship between AI adoption and software-delivery stability. AI-assisted development makes independent release validation more important, not less.

Evaluate the complete release candidate
Run code tests first, then validate the inputs that determine model behavior. Data-quality checks should reject unexpected schemas, missing required features, invalid ranges, and accidental inclusion of disallowed fields.
Evaluate the model against a versioned, fixed holdout set before allowing staging deployment. Compare against the approved baseline, and include subgroup, bias, or safety evaluations where the use case requires them. Set acceptance criteria before evaluating the candidate so teams can't adjust the bar to accommodate a disappointing result.
Keep these gates separately visible:
- Data gate: Record dataset identifiers, validation results, and feature-transformation versions.
- Model gate: Retain evaluation results, baseline comparisons, and applicable safety checks.
- Supply-chain gate: Scan dependencies and containers, verify signatures, and identify the approved model artifact.
- Operational gate: Check serving compatibility and monitor production behavior after release.
An internal dashboard and a clinical-support feature shouldn't share an identical approval policy. Assign risk tiers and require the appropriate reviewers and evaluation coverage for each, without presenting a pipeline pass as proof of regulatory compliance.
Preserve evidence without exposing patient data
Store an immutable release manifest containing the commit, build provenance, test results, model and dataset identifiers, approver, and deployment target. Tie that manifest to the complete release candidate, including configuration.
Don't put protected health data in pipeline logs. Use identifiers and hashes instead of raw records, restrict evidence access, and prevent diagnostic output from copying sensitive examples into general-purpose job logs.
Suppose a model update passes API tests but performs worse on the approved holdout evaluation for an important patient subgroup. The model gate blocks it before staging, preserves the evaluation evidence, and returns the candidate to its owner for investigation.
Metrics That Show Whether the Pipeline Works
Build duration alone is a poor measure of delivery performance. A short pipeline can still release defective software, while a fast build followed by a long approval queue doesn't deliver fast feedback to customers.
Track deployment frequency, change lead time, change failure rate, and failed-deployment recovery time. Define lead time from commit until the change runs successfully in production. Count production deployments requiring rollback, hotfix, or incident response when calculating change failure rate.
Use benchmarks as context
The DORA metrics guide provides the measurement framework and published performance bands summarized below. These are benchmarks, not release quotas or guarantees that a particular cadence suits your service.
DORA performance bands for pipeline outcomes
| Metric | Elite | High |
|---|---|---|
| Deployment frequency | Multiple deployments per day | Daily to weekly |
| Change lead time | Under one hour | Several hours to one week |
| Change failure rate | 0–15% | 16–30% |
| Time to recover from failed deployment | Under one hour | Under one day |
Instrument commit, build, test, approval, deployment, rollback, and recovery timestamps. Preserve the event history so a deployment can be connected to both its originating change and any remediation it caused.
Review weekly or monthly distributions rather than averages alone. Segment dashboards by service and change type, because an infrastructure update, routine application release, and emergency fix can follow different paths.
Read speed and stability together
If lead time falls while change failure rate rises, investigate missing regression coverage, ineffective canary signals, or approvals that don't evaluate meaningful evidence. Increasing deployment frequency won't fix those weaknesses.
If failure rates stay stable but lead times remain long, inspect the waiting periods. A queued environment, delayed review, or overloaded runner can dominate elapsed time even when individual jobs run quickly.
Galliot's guide to monitoring in DevOps helps connect delivery records with service health. Deployment completion and successful customer-facing behavior need to be distinguishable events in your dashboards.
Measurement safeguard: Don't declare a deployment successful until the service satisfies its post-deployment health criteria.
Use the review to choose a concrete change, such as removing an unnecessary serial dependency or replacing a weak smoke assertion. Then examine both delivery time and failure outcomes after the change, rather than celebrating a shorter job in isolation.
Avoid the common counting errors: failed attempts aren't successful deployments, emergency fixes shouldn't disappear into routine-release averages, and a completed deployment command doesn't establish recovery. Recovery ends when the affected service is healthy, not when someone clicks the rollback button.
Set Up Your First Pipeline This Week
Start with a service whose build command, runtime requirements, and owner are clear. Don't begin by designing a shared platform for every repository.
Build a small working path
On the first day, protect the main branch, require a peer review, and add an automated build that produces an artifact tagged with the commit SHA. Keep pipeline configuration in the repository so changes to release behavior receive review too.
Next, add unit tests and a dependency scan. Make high-severity findings blocking, and confirm that an intentionally failing test prevents downstream work. A gate that nobody has tested is only an assumption.
For the initial staging deployment, use a disposable environment and exercise these smoke-test behaviors:
- Startup: The deployed process becomes ready.
- Persistence: A synthetic request can write and retrieve test data.
- Core behavior: A representative API request returns the expected result.
Clean up synthetic data and environments after successful validation, while preserving failed environments long enough for controlled debugging.
Add production controls deliberately
During the following week, introduce a canary rollout with an explicit rollback condition. Record commit, build, deploy, and recovery events from the start, then add the test, approval, and remediation records needed for trustworthy outcome metrics.
Use Galliot's DevOps best practices to review ownership, automation, and operational readiness alongside the pipeline. Teams with limited capacity can't afford gates that consume maintenance time without catching relevant failures, but mandatory security and safety controls shouldn't wait for an incident.
At Galliot, we start with an engineer reviewing your infrastructure, pipelines, and cloud bill, then agree on a short list of what to fix first. Apply the same discipline internally: before adding the next stage, answer which failure would this catch that the current stages miss?
Galliot's Cloud & Platform Engineering service covers cloud platforms, Kubernetes, CI/CD, and the infrastructure behind ML models and AI agents, built by senior engineers inside your team. Visit Galliot to arrange an engineering call and identify the pipeline checks, release controls, and infrastructure fixes to prioritize first.
Get Started
Have a question? Send us a message and we will respond as soon as possible.
Leave us a comment