A well-designed CI/CD pipeline turns code changes into reliable releases with less manual effort. This guide is for DevOps engineers and platform teams who want a practical blueprint: workflow stages, tool selection trade-offs, and production-safe deployment patterns.
Originally published on 2010-05-17; fully revised and updated.
What CI/CD covers in practice
Continuous Integration (CI) focuses on frequent code integration, automated testing, and build validation. Continuous Delivery/Deployment (CD) extends that flow into release automation, with controls for risk and rollback.
- CI catches integration issues early with automated checks.
- CD reduces manual release steps and makes deployments repeatable.
- Both together improve lead time, consistency, and recovery speed.
Reference workflow from commit to production
A practical pipeline should validate quickly, produce traceable artifacts, and gate production rollout with clear approval and rollback paths.
flowchart TD
A[Developer pushes commit] --> B[Install dependencies]
B --> C[Run lint and unit tests]
C --> D{Tests pass}
D -- no --> E[Fail pipeline and fix]
D -- yes --> F[Build artifact or image]
F --> G[Push to artifact registry]
G --> H[Deploy to staging]
H --> I[Run smoke tests]
I --> J{Approve production release}
J -- no --> E
J -- yes --> K[Deploy to production]
Compare popular CI/CD platforms
Platform choice is usually driven by repository location, required control over runners, and how much operational overhead your team can absorb.
| Platform | Best for | Hosting model | Strengths | Trade-offs |
|---|---|---|---|---|
| Jenkins | Highly customized enterprise pipelines | Primarily self-managed | Flexible plugin ecosystem, deep customization | Higher maintenance and upgrade overhead |
| GitHub Actions | Teams already using GitHub repos | Cloud and self-hosted runners | Native GitHub integration, simple workflow syntax | Complex workflows can become hard to govern |
| GitLab CI/CD | Teams standardizing on GitLab | SaaS or self-managed | Integrated SCM and pipeline features | Best experience tied to GitLab ecosystem |
| CircleCI | Cloud-first teams needing quick setup | Cloud and self-hosted options | Fast onboarding, reusable config patterns | Less native when code is outside supported integrations |
Minimal pipeline example with GitHub Actions
This example runs tests on every push and pull request, then builds and pushes a container image for the main branch.
name: ci-cd
on:
push:
branches: [ "main" ]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- run: npm test
build_and_push:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build -t ghcr.io/example/app:${{ github.sha }} .
- run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- run: docker push ghcr.io/example/app:${{ github.sha }}Code language: JavaScript (javascript)
Deployment command example for Kubernetes
After publishing an image, update the deployment and wait for rollout status. Pair this with health checks and alerting in production.
export GIT_SHA=$(git rev-parse --short HEAD)
docker build -t ghcr.io/example/app:$GIT_SHA .
docker push ghcr.io/example/app:$GIT_SHA
kubectl set image deployment/app app=ghcr.io/example/app:$GIT_SHA -n production
kubectl rollout status deployment/app -n productionCode language: JavaScript (javascript)
Common pitfalls and best practices
- Pitfall: Long pipelines with slow feedback. Best practice: Run fast tests first, then heavier integration suites.
- Pitfall: Environment drift between staging and production. Best practice: Use the same deployment mechanism and immutable artifacts.
- Pitfall: Secrets exposed in logs. Best practice: Store secrets in a dedicated manager and mask sensitive output.
- Pitfall: No rollback plan. Best practice: Automate rollback or progressive delivery with clear health gates.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals