What is a CI/CD pipeline?
· Category: DevOps & CI/CD
Short answer
A CI/CD pipeline is an automated workflow that moves code from commit to production. It typically includes stages for build, test, security scan, package, deploy, and verify.
How it works
Each stage is a script or set of commands executed in a clean environment. Artifacts flow from one stage to the next. Failures stop the pipeline and notify the team. Approvals can gate production deployments.
Example
stages:
- build
- test
- scan
- deploy
build:
script:
- docker build -t myapp:$CI_COMMIT_SHA .
test:
script:
- pytest
scan:
script:
- trivy image myapp:$CI_COMMIT_SHA
deploy:
script:
- kubectl set image deployment/myapp app=myapp:$CI_COMMIT_SHA
Why it matters
Pipelines enforce consistency, reduce manual errors, and accelerate feedback loops. They provide a single source of truth for how software is built and delivered.
Tips
- Keep pipeline definitions in version control.
- Use artifacts to share data between stages.
- Parallelize independent stages to reduce total time.
Common issues
- Stages that depend on each other create bottlenecks.
- Large artifacts slow down transfer times.
- Secrets management is a common weak point.