Skip to main content

Pipeline

A CI/CD pipeline is an automated sequence of stages that takes code from a commit through build, test, scan, and deploy, so every change follows the same verified path to release.

Understanding CI/CD Pipelines

What Is a CI/CD Pipeline

A pipeline automates the path from a Git commit to running software. Continuous integration (CI) builds and tests every change. Continuous delivery or deployment (CD) then releases it, either after an approval or automatically. The value is repeatability: every release passes the same checks, in the same order, with a record of what happened.

Typical Stages

flowchart LR A[Commit] --> B[Build] B --> C[Test] C --> D[Scan] D --> E[Deploy staging] E --> F{Approval} F --> G[Deploy production] classDef code fill:#8B5CF6,color:#FFFFFF classDef check fill:#326CE5,color:#FFFFFF classDef prod fill:#10B981,color:#FFFFFF class A code class B,C,D,E check class F,G prod
  • Build: compile code and produce an artifact such as a container image.
  • Test: unit, integration, and coverage checks.
  • Scan: SAST, dependency, and image vulnerability scans.
  • Deploy: release to environments, with a manual gate before production if required.

Pipeline as Code

YAML
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build -t payment-api:${{ github.sha }} .
test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test
deploy-staging:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- run: ./scripts/deploy.sh staging

Storing the pipeline in the same repository as the code lets you review, version, and revert pipeline changes together with the application.

Ordering Stages for Fast Feedback

Order checks from fastest and cheapest to slowest: lint, unit tests, build, integration tests, deploy. A trivial syntax error should fail in seconds, not after a 15-minute suite. Aim for roughly under 10 minutes to staging, since slow pipelines train engineers to stop watching them.

Practical Commands

Bash
gh workflow run deploy.yaml
gh run list --workflow=deploy.yaml
gh run view 1234567890 --log
glab ci status

Troubleshooting

Symptom First check What to look for
Not triggering Trigger and branch filters Name or path mismatch
Stage fails silently Job logs Exit code and last command
Pipeline too slow Stage durations Independent jobs not parallel
Flaky failures Failure pattern history Tests depending on external state
Tip

Keep pipeline configuration in the application repository, so a pipeline change is traceable in the same Git history.

Remember

Build once and promote the same artifact through every environment. Never rebuild per environment.

Security

Pipelines hold deployment credentials. Mask secrets, never print them, prefer OIDC over stored keys, and audit who can approve production.

Common Mistake

Adding more stages to an already slow pipeline instead of making existing stages faster or parallel.

Frequently Asked Questions

What is the difference between a pipeline and a single CI job?

A job does one task and stops. A pipeline chains stages with gates between them, so a failure halts progress and nothing reaches production without passing every earlier check.

What is the difference between continuous delivery and continuous deployment?

In continuous delivery every change is ready to release and a person approves the final step. In continuous deployment passing changes go to production automatically with no manual approval.

How should I order pipeline stages?

Put the fastest, cheapest checks first, such as lint and unit tests, and slower integration and deploy steps later, so common mistakes fail within seconds.

Found a mistake, an outdated step or a broken link?