What is a CI/CD pipeline and what are its typical stages?
Learn what a CI/CD pipeline is and its typical stages — source, build, test, and deploy — plus how fail-fast gating keeps broken changes out of production.
Expected Interview Answer
A CI/CD pipeline is an automated, ordered sequence of stages that takes a code change from commit to production, running steps like build, test, and deploy so releases are fast, consistent, and repeatable. Each stage must pass before the next begins, and a failure stops the pipeline.
Typical stages are: source (a commit or pull request triggers the pipeline), build (compile code and produce an artifact), test (unit, integration, and other automated checks), and deploy (promote the artifact to staging and then production). Many pipelines add security or quality scans, artifact publishing, and post-deployment monitoring. The pipeline is defined as code (for example a YAML file) so it is version-controlled and reproducible.
- Automates the whole path from commit to production
- Fails fast, stopping bad changes before release
- Reproducible, version-controlled process defined as code
- Consistent environments reduce 'works on my machine' issues
- Clear visibility into where a change is and why it failed
- Enables frequent, low-risk releases
AI Mentor Explanation
A CI/CD pipeline is like a batter's journey through the innings: they pass net practice, get cleared by the physio, pad up, and only then walk to the crease — each gate must be passed in order. If the physio flags an injury, the batter does not proceed. The pipeline's build, test, and deploy stages are those sequential clearances that a code change must pass before reaching the field of production.
Step-by-Step Explanation
Step 1
Source
A commit or pull request to the repository triggers the pipeline automatically via a webhook.
Step 2
Build
The code is compiled and packaged into a versioned, deployable artifact in a clean environment.
Step 3
Test
Automated unit, integration, and sometimes end-to-end tests run; any failure stops the pipeline.
Step 4
Scan and quality gates
Optional security, dependency, and code-quality scans enforce standards before release.
Step 5
Deploy
The validated artifact is promoted to staging and then to production, often with monitoring and rollback.
What Interviewer Expects
- The core stages: source, build, test, deploy
- Understanding that stages run in order and fail fast
- Awareness of pipeline-as-code and version control
- Mention of extra stages like security scans or monitoring
- How a failed stage prevents a bad change from progressing
Common Mistakes
- Listing tools instead of describing the stages
- Omitting the test stage or treating it as optional
- Not knowing a failure should halt the pipeline
- Confusing the pipeline definition with the CI server itself
- Forgetting that pipelines are typically defined as code
Best Answer (HR Friendly)
“A CI/CD pipeline is an automated assembly line for software. It takes a code change and moves it through ordered steps — build, test, and deploy — and only lets it continue if each step passes, so releases are fast and reliable and broken changes get stopped early.”
Code Example
stages: [build, test, deploy]
build:
stage: build
script:
- npm ci
- npm run build
artifacts:
paths: [dist/]
test:
stage: test
script:
- npm test
deploy:
stage: deploy
script:
- ./deploy.sh production
only:
- mainFollow-up Questions
- What happens when a stage in the pipeline fails?
- Where do security scans fit in a CI/CD pipeline?
- What is a build artifact and why is it promoted between stages?
- How do staging and production deployments differ in a pipeline?
- What does 'pipeline as code' mean and why is it valuable?
MCQ Practice
1. Which is the typical correct order of CI/CD pipeline stages?
A pipeline is triggered at source, then builds an artifact, tests it, and finally deploys it, each stage gating the next.
2. What should happen when the test stage fails?
Pipelines fail fast: a failed stage stops progression so a broken change never reaches production.
Flash Cards
What is a CI/CD pipeline? — An automated, ordered sequence of stages that takes a code change from commit to production.
Name the typical pipeline stages. — Source, build, test, and deploy (often plus security scans and monitoring).
What happens when a stage fails? — The pipeline halts (fails fast) and the change is not promoted further.
What is 'pipeline as code'? — Defining the pipeline in a version-controlled config file so it is reproducible and reviewable.
Continue Learning
Related Interview Questions
What is CI/CD and what problems does it solve in software delivery?
easy
What is the difference between continuous integration, continuous delivery, and continuous deployment?
medium
How do you implement automated testing in a CI/CD pipeline?
medium
What is the difference between a smoke test and a full regression test in CI/CD?
easy