Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Jenkinsfile

Direct answer

A Jenkinsfile is the pipeline definition stored in the project's repository, so the build process is versioned and reviewed alongside the code.

When to use this

Use this when pipeline definitions live in the repository.

First 30 seconds

1. Jenkinsfile describes the pipeline.

2. Validate before commit.

3. Keep logic in shared libraries.

4. Avoid credentials in the file.

5. Review changes.

Operational verification

Jenkinsfile → validation → pipeline

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Jenkins controller/agent and Pipeline automation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformJenkins controller/agent and Pipeline automation · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when pipeline definitions live in the repository.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Common mistakes Narrow the fault
  • Logic in the Jenkins UI instead of the Jenkinsfile.
  • Secrets echoed in sh steps.
Evidence references

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.

observation · 1
Key points
  • The Jenkinsfile lives in the project repository.
  • Pipeline changes are reviewed like code.
  • Multibranch pipelines build each branch.
Key checks
  • Jenkinsfile in repo root — location
  • curl -X POST -F 'jenkinsfile=<Jenkinsfile' https://<jenkins>/pipeline-model-converter/validate — validate declarative syntax
  • Shared library usage — reuse
ReferenceWhy it matters1 section · depth on demand

What it is

A Jenkinsfile defines the pipeline as code in the repository (declarative or scripted syntax).

ReferenceHow it works1 section · depth on demand

In depth

pipeline {
  agent { label 'linux' }
  options { timeout(time: 30, unit: 'MINUTES'); disableConcurrentBuilds() }
  stages {
    stage('Lint')  { steps { sh 'yamllint . && ansible-lint' } }
    stage('Test')  { steps { sh 'pytest -q' } }
    stage('Deploy') {
      when { branch 'main' }
      steps { input 'Deploy to production?'; sh './deploy.sh' }
    }
  }
  post { failure { echo 'notify team' } }
}

Validate syntax before committing with the declarative linter (jenkins-cli declarative-linter < Jenkinsfile), and keep complex logic in scripts the Jenkinsfile calls, so it can be tested outside Jenkins.

ReferenceImportant terms & boundaries2 sections · depth on demand

Example

pipeline {
  agent { label 'linux' }
  stages {
    stage('Lint') { steps { sh 'ansible-lint' } }
    stage('Deploy') { when { branch 'main' } steps { sh 'ansible-playbook site.yml' } }
  }
}

Mechanics

Its durable intent is versioned Jenkinsfile/job configuration, credentials references and agent/tool constraints; the stable identity contract is controller, job/folder, build number, stage/step, agent and artifact IDs. The operating invariants are that Jenkinsfile revision is known, credentials stay scoped, agent/tool requirements are reproducible, stage status is not confused with target-evidence of the actual state, and artifacts are traceable to one build. The linked authority for bounded mechanics is Jenkins User Handbook; documentation support is separate from observed lab/production Evidence.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docJenkins controller/agent and Pipeline automation current

Authoritative/upstream documentation reviewed for bounded claims in Jenkins > Jenkinsfile. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.jenkins.io/doc/ · confidence 94%
Confirmation

Confirm action

Continue?