Skip to main content

CI/CD Pipelines

The one-sentence version

A pipeline turns a commit into a deployable artifact and then into running software, with automated checks at each step so failures are caught early and cheaply.

CI, delivery, deployment

Three terms that get used interchangeably and should not be.

TermMeans
Continuous IntegrationEvery push is automatically built and tested
Continuous DeliveryAlways deployable; production release is a manual decision
Continuous DeploymentEvery passing change goes to production automatically

The distinction that matters in an interview: delivery keeps a human gate, deployment does not.

Build once, promote the artifact

The most important pipeline principle, and the one most often broken.

Build the artifact once and promote that same artifact through environments. Rebuilding per environment means the thing you tested is not the thing you shipped — dependency resolution, base images and build tooling can all differ between runs.

This also makes rollback trivial: redeploy the previous artifact. If you instead rebuild from an old commit, you are hoping the build is reproducible under pressure.

Deployment strategies

Each trades infrastructure cost against rollback speed and risk exposure.

StrategyHowRollbackCost
RollingReplace instances in batchesSlow — roll forward againNone extra
Blue-greenTwo full environments, switch trafficInstant — switch back2x infrastructure
CanarySend a small % of traffic to the new versionFast — stop shiftingSlight
RecreateStop all, start newRedeployDowntime

Canary is the strongest option when you have real observability, because it limits the blast radius of a bad release to a fraction of users and gives you metrics to decide on. Without monitoring to watch, a canary is just a slower rolling deploy.

Secrets and safety

Pipelines run with credentials to your infrastructure, which makes them a serious target.

  • Store secrets in the platform's encrypted store, never in the YAML
  • Prefer short-lived credentials via OIDC over long-lived static keys
  • Do not expose secrets to workflows triggered by pull requests from forks
  • Pin third-party actions to a commit SHA, not a mutable tag

That last one matters: a tag like @v3 can be repointed by the action's owner, so a compromised upstream becomes code execution inside your pipeline with your credentials.

Why it passes locally and fails in CI

A near-universal experience, and the causes are a short list:

CauseCheck
Different runtime versionPin it explicitly in the workflow
Missing environment variableCompare local env against pipeline config
Uncommitted local filegit status — CI only has what you pushed
Stale cacheClear the dependency cache and retry
Case-sensitive filesystemLinux CI vs case-insensitive macOS

The last one bites regularly: import ./Utils works on macOS and fails on a Linux runner.

Questions

Loading questions…

Learn more