Use this when modelling build, test and deploy in Jenkins.
Pipeline · Jenkins
A Jenkins pipeline models the whole build, test and deploy process as code, with stages that show progress and can pause for approval.
1. Pipelines define builds as code (Groovy DSL).
2. Store Jenkinsfile in repo.
3. Multibranch pipelines.
4. Shared libraries.
5. Visual history.
Jenkinsfile → pipeline run → stages
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
Record controller, job/folder, build number, stage/step, agent and artifact IDs; inspect the runtime/control-plane result; then query the build/test/package/deployment result and any external system mutated by the Pipeline through an independent read path and compare it with the versioned intent. 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 SCM revision, stage/step graph, agent allocation, artifacts, credentials and final external target verification. For Jenkins → Pipeline, the evidence must connect the control-plane result to the build/test/package/deployment result and any external system mutated by the Pipeline and explain any gap between desired, controller-reported and consumer-visible state.
Step 2 Common mistakes Narrow the fault
- Pipelines without timeouts.
Step 3 Where it fails Narrow the fault
Common failure classes include controller/agent drift, plugin behavior changes, workspace contamination, credential leakage, retrying non-idempotent stages and green Pipeline status masking bad external state.
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.
- Pipelines model build, test and deploy as code.
- Stages show progress.
- input steps pause for approval.
- Pipeline job type — as code
- Stage view/Blue Ocean history — runs
- Replay disabled for sensitive pipelines — control
ReferenceWhy it matters1 section · depth on demand
Worked example
A Jenkins pipeline describes the whole build and delivery process as code (a Jenkinsfile), from checkout to deployment. Pipelines survive controller restarts, can pause for input, run stages in parallel and are versioned with the project.
Worked example — a pipeline for an Ansible repository:
pipeline {
agent { docker { image 'registry.example.com/ansible-ee:2.16' } }
options { timeout(time: 45, unit: 'MINUTES'); buildDiscarder(logRotator(numToKeepStr: '30')) }
stages {
stage('Lint') { steps { sh 'yamllint . && ansible-lint' } }
stage('Preview') { steps { sh 'ansible-playbook site.yml -i inventories/prod --check --diff | tee preview.txt' } }
stage('Apply') {
when { branch 'main' }
steps { input message: 'Apply to production?', submitter: 'netops-leads'
sh 'ansible-playbook site.yml -i inventories/prod' }
}
}
post { always { archiveArtifacts 'preview.txt' } }
}
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
Jenkins → Pipeline is owned at runtime by the Jenkins controller, queue, Pipeline engine and selected agents/executors. The consumer-visible target is the build/test/package/deployment result and any external system mutated by the Pipeline. The linked authority for bounded mechanics is Jenkins Handbook — Pipeline; 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 > Pipeline. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.jenkins.io/doc/book/pipeline/ · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For SCM revision, stage/step graph, agent allocation, artifacts, credentials and final external target verification, prefer typed fields and stable IDs over human presentation text.