Promoting Code with Pipeline Stages

Think of pipeline stages as quality gates. Code must pass one gate, like 'build', before being promoted to the next, like 'deploy to staging'. This is core to CI/CD, moving code safely from dev to production. The footgun is making later stages less strict.
Why it exists
To solve the problem of shipping code directly from a developer's machine to production. Without a structured promotion process, you risk deploying broken, untested, or insecure code, leading to outages. Staged promotion creates a predictable, repeatable, and safe path for software to reach users.
The mental model
A pipeline is an assembly line for your code. Each stage is a workstation on that line. The 'Build' stage assembles the parts. The 'Test' stage runs quality checks. The 'Staging' stage does a final dress rehearsal. The 'Production' stage is the final delivery to the customer. You don't ship a car from the first workstation; you promote it down the line only after it passes inspection at each step.
How it works
In a CI/CD tool like Azure Pipelines, you define a series of stages. Each stage is a logical boundary containing one or more jobs, like building code or running tests. By default, stages run sequentially; Stage 'B' only starts if Stage 'A' succeeds. This creates a promotion model where an artifact must pass the checks of one stage to be eligible for the next. You can also add conditions, dependencies, and gates. For example, promotion to the 'Production' stage might require manual approval from a manager, while promotion from 'Build' to 'Test' is fully automatic upon success.
When to use it
Use a multi-stage pipeline for any application that requires more than a simple build-and-test. It's essential for any service with distinct environments (e.g., staging, production). This structure is the foundation of modern CI/CD, providing visibility and control over how code moves from commit to customer.
When not to use it
For very simple projects, like a small command-line tool or a script that doesn't get 'deployed' to an environment, a single-stage pipeline with just build and test jobs is sufficient. Adding multiple stages can be overkill if there are no distinct environments or deployment processes to model.
One canonical example
A common four-stage pipeline for a web service: First, the 'Build' stage compiles the code and runs static analysis. Second, the 'Test' stage runs unit and integration tests against the built artifact. Third, the 'Staging' stage deploys the artifact to a staging environment that mirrors production and runs end-to-end tests. Fourth, the 'Production' stage deploys the same verified artifact to users, often after a manual approval gate.
Interview question
What fundamental principle dictates how code progresses from one stage to the next in a CI/CD pipeline?
- a.Stages are designed to run concurrently to minimize the overall deployment time.
- b.Each stage serves as a quality gate, requiring successful completion before code can advance.Correct
- c.Code automatically moves to the next stage upon completion of the current stage, even if errors occurred.
- d.All stage transitions require explicit manual approval from a designated team member.
Why? this is the answer
The card states that 'Stage 'B' only starts if Stage 'A' succeeds,' establishing that each stage acts as a quality gate. Code must pass the checks of one stage to be eligible for the next, making option B correct. Option C is incorrect because progression is conditional on success, not just completion.
Just read this? Test yourself on what you have been reading.
Read the original → learn.microsoft.com
- #ci/cd
- #devops
- #azure pipelines
- #deployment
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on ci/cd — each one lists the topics its interview covers.
See open roles