DevOps, CI/CD & Containers

Continuous Delivery Pipelines: Stages, Artifacts and Deployment Strategies

Intermediate9 min readUpdated

A deployment pipeline is the automated path from a commit to a running release, with each stage adding confidence that the change is safe. This guide explains how to design the stages, why you build an artifact once and promote it through environments, how to version releases and evolve database schemas without downtime, and when to choose rolling, blue-green or canary deployments.

What you will learn

  • Distinguish continuous integration, continuous delivery and continuous deployment
  • Design a pipeline whose stages build once and promote the same artifact through environments
  • Version artifacts with semantic versioning and store them in an artifact repository
  • Apply expand-and-contract database migrations that stay compatible with the running version
  • Choose between rolling, blue-green and canary deployment strategies and plan a rollback

Continuous integration proves that the code compiles and its tests pass. That is necessary and nowhere near sufficient for a release: the packaged artifact still has to be configured for an environment, deployed next to a database whose schema may need to change, checked against real dependencies, and switched into live traffic in a way that does not drop requests. A deployment pipeline automates that path from commit to production, with each stage adding evidence that the change is safe. Continuous delivery is the state in which the pipeline is trustworthy enough that any green build could be released at the push of a button; continuous deployment is when you take the button away. This guide is about designing that pipeline.

Delivery, deployment and the definition of releasable

Three terms are often mixed up:

  • Continuous integration — every merge is built and tested automatically.
  • Continuous delivery — every build that passes the pipeline is packaged, versioned and verified in production-like environments, so it can be released at any time with a manual decision.
  • Continuous deployment — every passing build is released to production automatically.

The gap between the second and third is a business choice, not a technical one. What is not a choice is the pipeline's job: to show, for every commit, whether it is releasable, and to make releasing a routine action rather than an event. If releasing still involves a spreadsheet of manual steps and a weekend, you have a CI server, not continuous delivery.

The stages of a pipeline

A pipeline moves the same change through stages that trade speed for confidence. A representative sequence for a backend service:

StageEnvironmentPurposeGate
CommitCI runnerCompile, unit tests, static analysis, package, publish artifactAutomatic
IntegrationCI runner with containersTests against a real database, broker, and dependent services' contractsAutomatic
AcceptanceDedicated test environment, deployed from the artifactEnd-to-end functional tests, security scansAutomatic
Staging / pre-productionProduction-like sizing and data shapePerformance tests, smoke tests, manual exploratory testing if neededAutomatic or manual approval
ProductionLiveProgressive rollout, health verification, rollback on failureManual approval (delivery) or automatic (deployment)

Two properties matter more than the exact list. First, stages run in order with fail-fast semantics: a failure in the commit stage means nothing later executes, so cheap failures are reported in minutes and expensive environments are not wasted. Second, every stage after the first operates on the same artifact, deployed with the same automation used for production. Deploying to the acceptance environment with the production deploy script is the test of that script.

Build once, promote everywhere

The rule that shapes everything else: build the artifact once, then promote it. The commit stage produces a jar, a container image, a zip of static files — with a unique version — and pushes it to an artifact repository. Later stages pull that exact artifact by version and deploy it. Nothing is recompiled.

Consequences:

  • The artifact must not contain environment-specific values. Database URLs, credentials, feature flags and hostnames are injected at deployment time via environment variables, mounted configuration files or a configuration service. The twelve-factor "config" principle is exactly this.
  • The artifact needs a stable home: Sonatype Nexus, JFrog Artifactory, GitHub Packages, a container registry such as Harbor or Amazon ECR. The repository is the source of truth for what exists and what has been deployed where.
  • The artifact must be immutable. Republishing version 2.3.1 with different contents is a lie to every environment that already pulled it. Container registries support this with digests (sha256:…); artifact repositories with "release" repositories that refuse overwrites.
  • Traceability becomes trivial: a version maps to a commit, a build number and a set of deployments.

Versioning

Choose a scheme and apply it mechanically. Two dominate.

Semantic versioning (MAJOR.MINOR.PATCH) communicates compatibility: a patch fixes bugs, a minor adds backward-compatible features, a major breaks compatibility. It is the right choice for libraries and for any API other teams depend on. Pre-release builds carry a suffix — 2.4.0-rc.1 — and build metadata a + suffix.

Build-number or commit-based versions (1.0.437, 2026.09.07-a1b2c3d) suit services that are only ever deployed, never consumed as a dependency. The version answers "which commit is this?" rather than "what did it break?".

Whatever the scheme, the pipeline assigns the version, not a developer's editor. In Maven that means dropping -SNAPSHOT at release time with the release plugin, versions:set, or the CI-friendly ${revision} property; for containers it means tagging the image with the version and pushing the digest into the deployment manifest.

# CI-friendly Maven versioning: the pipeline supplies the revision
mvn -B -Drevision=1.4.$BUILD_NUMBER deploy

# Tag the image twice: a human-readable version and the commit
docker build -t registry.example.com/shop/orders:1.4.$BUILD_NUMBER \
             -t registry.example.com/shop/orders:$GIT_COMMIT .
docker push --all-tags registry.example.com/shop/orders

Database migrations

Databases are the hardest part of continuous delivery because a schema, unlike a container, cannot simply be replaced. Two tools dominate in the Java world — Flyway (versioned SQL scripts) and Liquibase (changelogs in XML, YAML or SQL) — and both work the same way: migration scripts live in version control next to the code, each carries a version, the tool records which have been applied in a metadata table, and on start-up or as a pipeline step it applies the missing ones in order.

-- src/main/resources/db/migration/V12__add_order_channel.sql
ALTER TABLE orders ADD COLUMN channel VARCHAR(20);
UPDATE orders SET channel = 'web' WHERE channel IS NULL;

The discipline that makes migrations safe is expand and contract. A schema change that the previous version of the code cannot tolerate breaks rolling deployments (old and new instances run simultaneously) and makes rollback impossible. So split every breaking change into compatible steps:

  1. Expand

    Add the new column, table or index without removing anything. The running version ignores it.
  2. Deploy code that writes both

    The new version writes to the old and the new structure and reads from the old. Rollback is safe: the old code still finds everything it needs.
  3. Backfill

    A migration or batch job copies historical data into the new structure.
  4. Deploy code that reads the new structure

    Now nothing depends on the old column except the dual write.
  5. Contract

    In a later release, stop writing the old structure and drop it.

This takes more releases than a single ALTER TABLE ... RENAME, which is precisely the point: each release is small, compatible with its neighbour, and reversible.

Deployment strategies

Once the artifact and schema are ready, the last stage is switching traffic. The strategies differ in capacity cost, exposure and rollback speed.

Recreate stops the old version, then starts the new. Simple, and the only option when two versions genuinely cannot coexist, but it means downtime. Acceptable for internal batch systems, not for a public API.

Rolling replaces instances a few at a time — Kubernetes Deployments do this by default, controlled by maxSurge and maxUnavailable. No downtime and no extra capacity, but old and new versions serve traffic simultaneously for the duration, so the change must be compatible in both directions (which the expand-and-contract discipline guarantees).

# Deployment excerpt: rolling update that never drops below full capacity
spec:
  replicas: 6
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 2          # up to 8 pods during the rollout
      maxUnavailable: 0    # never fewer than 6 ready pods
  template:
    spec:
      containers:
        - name: orders
          image: registry.example.com/shop/orders@sha256:3f1c…   # immutable reference
          readinessProbe:
            httpGet: { path: /actuator/health/readiness, port: 8080 }

The readiness probe is what makes rolling safe: Kubernetes only sends traffic to a new pod once the probe succeeds, and only removes an old one once enough new ones are ready.

Blue-green runs two complete environments. Blue serves production; green receives the new version, is smoke-tested, then the router or load balancer switches all traffic to green. Rollback is switching back. The costs are double capacity during the switch and a database shared by both colours, which again requires compatible schema changes.

Canary sends a small percentage of traffic (1 %, then 10 %, then 50 %) to the new version while watching error rate and latency, and either advances or aborts automatically. It is the lowest-risk strategy for user-facing services but demands good metrics and a traffic-splitting layer — a service mesh, an ingress controller with weighted routing, or a tool such as Argo Rollouts or Flagger.

Feature flags are orthogonal: the code is deployed to everyone but the feature is off until a flag turns it on for a cohort. Flags decouple deployment from release and allow instant "rollback" by flipping the flag, at the price of dead code paths that must eventually be cleaned up.

Rollback and verification

Every pipeline needs an answer to "what happens when production is wrong?" that takes minutes, not a war room.

  • Roll forward by redeploying the previous artifact. Because artifacts are immutable and versioned, the previous version is a known-good input to the same deploy step. kubectl rollout undo does this for a Deployment; a blue-green switch is a router change.
  • Never roll back the database. With expand-and-contract, the previous code works against the new schema; a "down migration" against production data is far riskier than the bug you are escaping.
  • Automate the health check after deploy. A smoke test that hits a few endpoints, and a short soak watching the error rate, catch most bad releases before a user reports them. Argo Rollouts and Flagger make the abort automatic; a simpler pipeline can run a script and fail the stage.

Approvals and compliance

Regulated environments often require a separated approver, an audit trail and a change record. A pipeline satisfies these better than a meeting: the input step in a Jenkins pipeline or an environment protection rule in GitHub records who approved what and when, the artifact version and commit are part of the log, and the deploy script is itself version-controlled and reviewable. What auditors need is evidence of control, and an automated pipeline produces more of it than a manual process ever did.

Common mistakes

  • Environment-specific builds. A mvn package -Pprod that bakes production URLs into the jar means staging tested something else. Externalise configuration.
  • Snapshot artifacts in production. 1.4-SNAPSHOT can change under you between staging and production. Release versions only.
  • Manual steps hidden in the pipeline. A stage that says "run the SQL script from the ticket" is not automated. If a human must do something, the pipeline should do it for them and record it.
  • Testing the deployment for the first time in production. Deploy to every lower environment with the production automation. Deploy scripts have bugs too.
  • Down migrations as the rollback plan. They are rarely tested and frequently destructive. Design forward-compatible schema changes instead.
  • Rolling out without readiness checks. A rolling update where every pod reports ready the instant the process starts serves errors from instances that have not finished warming up. Wire the readiness probe to something meaningful.
  • Treating the pipeline as done. Lead time creeps up as stages are added. Measure commit-to-production time and remove waiting.

Key takeaways

  • A deployment pipeline is the automated, ordered sequence of stages that proves each commit releasable; continuous delivery is having that pipeline, continuous deployment is letting it release without asking.
  • Build the artifact once, version it, store it immutably, and promote the same bytes through every environment with configuration injected at deploy time.
  • Assign versions in the pipeline: semantic versioning for anything others depend on, build or commit-based versions for deployables.
  • Apply database changes as versioned migrations in expand-and-contract steps so that consecutive releases are compatible in both directions and rollback never touches the schema.
  • Choose the deployment strategy by risk and capacity: rolling for most services, blue-green for instant switch and rollback, canary when metrics can judge a slice of traffic.
  • Rollback means redeploying the previous artifact in minutes; verify every deployment automatically with smoke tests and error-rate monitoring.

Sources and further reading

Frequently asked questions

What is the difference between continuous delivery and continuous deployment?
Continuous delivery means every change that passes the pipeline is proven deployable and can be released to production with a single action, but a human decides when. Continuous deployment removes that decision: every green build is released automatically. Delivery is a prerequisite for deployment; many regulated or customer-facing teams stop at delivery deliberately so that releases can be timed.
Why should I not rebuild the application for each environment?
Because the artifact you tested in staging would then differ from the one you run in production — a different compiler run, possibly different dependency resolution, and any environment-specific value baked in. Build one artifact, store it with a version, and inject environment differences at deploy time through configuration. Then a green staging run is evidence about the exact bytes going to production.
How do I deploy a database change without downtime?
Split it into backward-compatible steps. Add the new column or table first, deploy code that writes to both old and new, backfill the data, deploy code that reads from the new location only, and drop the old structure in a later release. Each deployment is compatible with the previous version of the code, so a rollback never needs a schema rollback.
When is a canary release better than blue-green?
Use a canary when you can observe the new version's error rate and latency on a slice of real traffic and want risk to grow gradually. Blue-green is simpler and gives an instant switch and instant rollback, but it exposes all users at once and needs double the capacity during the switch. If you have no metrics good enough to judge a canary, blue-green with a fast rollback is the safer choice.