Skip to main content

Jenkinsfile Lint

CI codecov PyPI version

Catch Jenkinsfile syntax errors before they break your CI.

jenkinsfilelint checks your Declarative Pipeline syntax offline, with no Jenkins at all, or with your Jenkins's own validator (/pipeline-model-converter/validate) when you configure one. It's primarily a pre-commit hook, but also works as a standalone CLI tool.

📖 Read the official blog post for the story behind this tool.

demo

Table of Contents

Quick Start

pip install jenkinsfilelint
jenkinsfilelint Jenkinsfile

That works as is: with no Jenkins server configured, files are checked offline. Then add the pre-commit hook (see below) or keep using the CLI.

Which mode?

Offline Remote Local (--local)
Used when no Jenkins server is configured, or with --offline JENKINS_URL (or --jenkins-url) is set --local is given
Needs nothing else a Jenkins server and credentials Docker or Podman
Speed milliseconds a network round trip 20–40 s first run, then fast
Groovy syntax and Declarative structure ✓ ✓ ✓
Step names and parameters, plugin agent types, tools — ✓ ✓ (plugins in the image)

Offline mode is the quick check that works anywhere, including CI images and machines without Docker. Remote and local mode ask a real Jenkins, so they also catch mistakes that depend on the plugins it has installed.

Any Jenkins setting (JENKINS_URL, JENKINS_USER or JENKINS_TOKEN, or the matching flag) selects remote mode. So a CI job that sets JENKINS_TOKEN but lost its JENKINS_URL secret fails with "Jenkins URL not provided" instead of quietly checking less. --offline checks offline even if a Jenkins server is configured.

Pre-commit Hook

Add the hook to your .pre-commit-config.yaml and install. Once configured, every commit that touches a Jenkinsfile is automatically validated.

Offline mode (no Jenkins, Docker or JVM)

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/jenkinsci/jenkinsfilelint
    rev: # use the latest version
    hooks:
      - id: jenkinsfilelint-offline
pip install pre-commit
pre-commit install

Nothing else to install or configure: no credentials, no container, no Rust toolchain. The check runs jenkinsfilelint --offline, which uses a small native engine that ships as a prebuilt wheel. The jenkinsfilelint hook does the same when no Jenkins server is configured; jenkinsfilelint-offline stays offline even when JENKINS_URL is set in your shell. It reports errors with the same wording as Jenkins's validator, at the line and column where they are:

git commit -m "Update Jenkinsfile"
jenkinsfilelint (offline)................................................Failed
- hook id: jenkinsfilelint-offline
- exit code: 1

Jenkinsfile:4:9: error: Expected one of "steps", "stages", or "parallel" for stage "Build"
Jenkinsfile:5:13: error: Unknown stage section "step". Starting with version 0.5, steps in a stage must be in a ‘steps’ block.

It checks Groovy syntax and the Declarative structure: required and allowed sections, stages, agent, environment, options, triggers, parameters, when, post, matrix and so on. On the test files of Jenkins's own validator it passes all 287 valid files and catches all 90 invalid ones that do not depend on plugins. It cannot know which plugins your Jenkins has, so it does not check step names and parameters or tool installations, and it only warns about agent types it does not know. Use remote or local mode for those.

Remote mode (with a Jenkins server)

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/jenkinsci/jenkinsfilelint
    rev: # use the latest or a specific version, e.g. v1.4.0
    hooks:
      - id: jenkinsfilelint

Set credentials via environment variables, then install:

export JENKINS_URL=https://jenkins.example.com
export JENKINS_USER=your-username
export JENKINS_TOKEN=your-api-token

pip install pre-commit
pre-commit install

Local mode (with Docker, no Jenkins server needed)

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/jenkinsci/jenkinsfilelint
    rev: # use the latest or a specific version, e.g. v1.4.0
    hooks:
      - id: jenkinsfilelint
        args: ["--local"]

Docker (or Podman) is the only requirement — no credentials needed:

pip install pre-commit
pre-commit install

The first commit pulls a minimal Jenkins container (~20–40s cold start). Subsequent commits reuse the running container and complete in milliseconds.

When you're done, stop the container:

jenkinsfilelint server stop

What happens on commit

A valid file passes silently:

git commit -m "Update Jenkinsfile"
jenkinsfilelint..........................................................Passed

A syntax error blocks the commit with a clear message:

git commit -m "Update Jenkinsfile"
jenkinsfilelint..........................................................Failed
- hook id: jenkinsfilelint
- exit code: 1

Errors encountered validating Jenkinsfile:
WorkflowScript: 17: Expected a step @ line 17, column 11.
             test
             ^

Fix the error and re-commit.

CLI

You can also run jenkinsfilelint directly on any file:

pip install jenkinsfilelint

jenkinsfilelint Jenkinsfile                   # offline, or remote if JENKINS_URL is set
jenkinsfilelint Jenkinsfile Jenkinsfile.prod tests/Jenkinsfile
jenkinsfilelint --local Jenkinsfile           # a Jenkins in Docker
jenkinsfilelint --offline Jenkinsfile         # offline, even if JENKINS_URL is set

With --verbose, a run that checks offline because no Jenkins server is configured starts by saying so:

ℹ No Jenkins server configured, so checking offline: step names, step parameters and other plugin-dependent checks are skipped. Set JENKINS_URL to check with Jenkins.

The exit code is 0 when every file is valid and 1 when any file has an error or could not be checked.

Filtering files

Use --include (whitelist) and --skip (blacklist) to control which files are validated:

# Only validate Jenkinsfiles
jenkinsfilelint --include 'Jenkinsfile*' Jenkinsfile src/Utils.groovy

# Exclude shared-library helper classes
jenkinsfilelint --skip '*/src/*.groovy' --skip 'vars/*.groovy' Jenkinsfile src/Utils.groovy

These work in every mode and in pre-commit too (with either hook id):

Exclude non-pipeline Groovy files (shared library helpers):

- id: jenkinsfilelint
  args: ["--skip=*/src/*.groovy", "--skip=vars/*.groovy"]

Only validate files matching specific patterns:

- id: jenkinsfilelint
  args: ["--include=Jenkinsfile*", "--include=pipelines/*.groovy"]

You can also combine both — --include narrows first, then --skip removes from that set:

- id: jenkinsfilelint
  args: ["--include=Jenkinsfile*", "--skip=*/src/*.groovy"]

Parallel validation

Files are validated 8 at a time over reused (keep-alive) connections, so a repository with many pipelines no longer pays one full round trip and TLS handshake per file. Results are still printed in the order the files were given.

Use --jobs / -j to change how many requests are in flight at once — for example to go easier on a shared Jenkins controller:

- id: jenkinsfilelint
  args: ["--jobs=4"]  # use --jobs=1 to validate one file at a time

The hook runs as a single process (require_serial: true), so --jobs is the total load it puts on Jenkins. Overriding require_serial: false in your config would multiply that by the number of CPUs pre-commit uses, and in --local mode would race to start the container.

Configuration

Supply credentials via environment variables (recommended) or CLI flags:

Env Variable CLI Flag Required
JENKINS_URL --jenkins-url No *
JENKINS_USER --username No **
JENKINS_TOKEN --token No **
JENKINSFILELINT_SERVER_IMAGE — No
JENKINSFILELINT_ENGINE — No ***

* Required for remote mode. Without any Jenkins setting, files are checked offline. ** Only required if your Jenkins requires authentication (not used in --local or --offline mode). *** Path of an engine binary for offline mode to use instead of the installed one.

CLI flags override env vars. There is no config file.

Local Docker image

By default, --local mode uses the official image ghcr.io/jenkinsci/jenkinsfilelint-server:latest, which includes the following plugins to cover common Declarative Pipeline constructs:

Plugin Common pattern enabled
docker-workflow agent { docker '…' }, docker.image('…')
git git url: '…'
credentials-binding withCredentials([…]) { … }
timestamper options { timestamps() }
ws-cleanup post { always { cleanWs() } }
pipeline-utility-steps readJSON, readYAML, findFiles

This list is a curated starting point — not exhaustive. If your Jenkinsfile uses a plugin not listed here (e.g. kubernetes, pipeline-github-lib), please open an issue to propose adding it, or use a custom image (see below).

Custom image

Build a custom image matching your production Jenkins setup and point to it via JENKINSFILELINT_SERVER_IMAGE:

# Export plugin list from your Jenkins (Script Console or Jenkins CLI)
# and generate plugins.txt + a Dockerfile, then:
docker build -t my-company/jenkinsfilelint-server:custom .
JENKINSFILELINT_SERVER_IMAGE=my-company/jenkinsfilelint-server:custom \
  jenkinsfilelint --local Jenkinsfile

The existing Dockerfile and plugins.txt are a good starting template — fork them and adjust the plugin list to match your production Jenkins.

A full Jenkins plugin list can be 100+ entries, which increases build time and image size. Only add what you need.

Security

  • Never put --token or --username in .pre-commit-config.yaml — use environment variables.
  • Use an API token, not your password.
  • A regular user token with read access is sufficient — no need for admin privileges.

How It Works

jenkinsfilelint answers one question: "Will Jenkins accept this syntax?" It either checks the file itself, offline, or POSTs it to a Jenkins's /pipeline-model-converter/validate endpoint.

  • Remote mode: validates against your existing Jenkins server using the URL and credentials you configure. Used whenever a Jenkins setting is present.
  • Local mode (--local): automatically starts a lightweight Jenkins container (via Docker or Podman) and validates against it. The container is reused across runs for near-instant validation.
  • Offline mode (--offline, and whenever no Jenkins server is configured): no Jenkins at all. The jenkinsfilelint-engine package, a dependency of jenkinsfilelint, parses the file and checks the Declarative rules itself, using the messages of Jenkins's validator. One run checks all files in milliseconds.

Scripted Pipelines and other Groovy files. The endpoint only checks Declarative syntax. For a file with no pipeline { … } block (a Scripted Pipeline, a shared-library vars/*.groovy step, an empty file) Jenkins still parses the Groovy, so syntax errors such as an unclosed brace fail as usual. If it parses, the file is reported as skipped and does not fail the run (⊘ vars/notify.groovy: Skipped (not a Declarative Pipeline) with --verbose). Offline mode does the same. To keep such files from being checked at all, use --skip / --include.

Requirements

  • Python 3.10+
  • For remote mode: a Jenkins server with the Pipeline plugin installed
  • For --local mode: Docker or Podman
  • For offline mode: nothing more on Linux (x86_64, aarch64, i686, armv7; glibc or musl), macOS (Intel, Apple silicon) and Windows (x86_64, x86), where pip install jenkinsfilelint installs a prebuilt engine. Elsewhere, pip install jenkinsfilelint-engine builds it from source and needs a Rust toolchain; the other modes work without it.

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE.

Metadata

Release files for jenkinsfilelint 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jenkinsfilelint 1.6.0
File Size Uploaded Provenance Actions
jenkinsfilelint-1.6.0.tar.gz 492.3 kB With provenance Details for jenkinsfilelint-1.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jenkinsfilelint 1.6.0
File Interpreter ABI Platform Actions
jenkinsfilelint-1.6.0-py3-none-any.whl Python 3 none any Details for jenkinsfilelint-1.6.0-py3-none-any.whl

Total release size: 513.5 kB

Release files / jenkinsfilelint-1.6.0.tar.gz

Download URL jenkinsfilelint-1.6.0.tar.gz
Size 492.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9c151c86fb788dc233a25c520201c4e49963c99fa562ea4e040df2c916eaebfa
BLAKE2b-256 checksum
How to use checksums
52f79722dc155790c4ab5f10a2e64a94e2c6fbf0ed21b1b244845845aff5f684
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / jenkinsfilelint-1.6.0-py3-none-any.whl

Download URL jenkinsfilelint-1.6.0-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd98b89b4e40845984abb6daf0a22d250c8bbdfcbd9832a53d3170c976fba7e6
BLAKE2b-256 checksum
How to use checksums
12a5c4abf457dd44a9d87cb7d08a44abfd713f3ac42e6d1f0a2d810be7e49fc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for jenkinsfilelint 1.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jenkinsfilelint-1.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page