CI/CD & Deployment interview question · Most asked
What is pipeline as code and why does it matter?
Definition Asked in DevOps Engineer · Site Reliability Engineer (SRE) · QA Engineer / SDET interviews
Summary
Pipeline as code means defining your CI/CD pipeline in a version-controlled file
(Jenkinsfile, .github/workflows/*.yml, .gitlab-ci.yml) rather than configuring it
through a web UI. Changes to the pipeline are reviewed, tested and audited like
application code.
Longer Answer
Before pipeline as code, CI/CD configurations lived in a web UI (Jenkins job config, TeamCity settings). Changes were untracked — you couldn't tell who changed the deploy step, when, or why. Rolling back a broken pipeline meant recreating it from memory.
Benefits:
- Version control: every pipeline change is a commit with a message, an author
and a diff.
git blametells you why the test step was changed last Tuesday. - Code review: pipeline changes go through pull requests. A reviewer can catch a missing approval gate or an insecure secret reference before it reaches production.
- Reproducibility: the pipeline definition travels with the code. Checking out an old branch gives you the pipeline that existed at that time.
- Branch-specific pipelines: a feature branch can modify its own pipeline (add a new test suite, change a deploy target) without affecting other branches.
- Disaster recovery: if the CI server is lost, the pipeline definition is in Git. Set up a new server and point it at the repository.
Common formats:
- GitHub Actions:
.github/workflows/*.yml— event-driven, marketplace actions. - GitLab CI:
.gitlab-ci.yml— stages and jobs, integrated with GitLab. - Jenkins:
Jenkinsfile— declarative or scripted Groovy, shared libraries. - Azure Pipelines:
azure-pipelines.yml— stages, jobs, templates. - CircleCI:
.circleci/config.yml— orbs for reusable components.
Best practice: treat the pipeline file with the same rigour as application code. Lint it, template shared patterns (reusable workflows in GitHub Actions, includes in GitLab CI), and test changes on a branch before merging.
Key Points
- Pipeline definitions live in version control alongside the application code
- Changes are reviewed, audited and can be rolled back like any other code change
- Branch-specific pipelines let feature branches modify their own CI without affecting others
- If the CI server is lost, the pipeline is recoverable from Git
Explanation
What interviewers look for
Look for understanding of why UI-configured pipelines are problematic (untracked, unreviewable, unreproducible). Weak answers just name the file format. Strong answers explain the operational benefits: review, audit trail, disaster recovery.
More CI/CD & Deployment questions
- What is shift-left testing, and what security scanning belongs in a CI pipeline?
- What are best practices for writing Dockerfiles?
- How do you handle flaky tests in CI?
- How would you design CI/CD for a microservices architecture?
- What's the difference between continuous integration, continuous delivery and continuous deployment?
- How do you promote a single build artifact from development through staging to production?
- Compare rolling, blue-green and canary deployments.
- What stages does a typical CI/CD pipeline contain?