Use this when dividing Jenkins pipelines into stages.
Stages
Stages divide a Jenkins pipeline into named phases such as Build, Test and Deploy, shown in the stage view, and can run conditionally with when or in parallel.
1. Stages group steps.
2. Clear names (Build, Test, Deploy).
3. Parallel where independent.
4. Fail fast.
5. Visualised in stage view.
stage → steps
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as controller/agent drift, plugin behavior changes, workspace contamination, credential leakage, retrying non-idempotent stages and green Pipeline status masking bad external state, choosing the cases most relevant to stage ordering/parallelism, conditions/post actions, stage-specific agents and distinguishing stage success from artifact/deployment correctness.
Step 2 Common mistakes Narrow the fault
- One giant stage, hiding where failures happen.
- Parallel stages writing to the same files.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Stages are named phases like Build, Test, Deploy.
- when{} makes stages conditional.
- parallel{} runs stages at once.
- Stage names and order — structure
- Parallel stages — speed
- Stage timing — bottlenecks
ReferenceWhy it matters1 section · depth on demand
What it is
Stages group pipeline steps (Build, Test, Deploy) and show progress in the UI; a failed stage stops later ones.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Stages divide a pipeline into named phases — lint, test, build, deploy — that appear in the UI and logs. They show at a glance where a run failed and how long each phase takes, and they are the unit for conditions, approvals, parallelism and agents.
stages {
stage('Validate') {
parallel {
stage('YAML') { steps { sh 'yamllint .' } }
stage('Ansible') { steps { sh 'ansible-lint' } }
}
}
stage('Deploy test') { steps { sh './deploy.sh test' } }
stage('Deploy prod') {
when { branch 'main' }
input { message 'Deploy to production?' }
steps { sh './deploy.sh prod' }
}
}
Keep stage names stable: dashboards and stage-level metrics depend on them.
Mechanics
The linked authority for bounded mechanics is Jenkins Handbook — Pipeline Syntax; documentation support is separate from observed lab/production Evidence.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Jenkins > Stages. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.jenkins.io/doc/book/pipeline/syntax/ · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For stage ordering/parallelism, conditions/post actions, stage-specific agents and distinguishing stage success from artifact/deployment correctness, prefer typed fields and stable IDs over human presentation text.