Skip to main content

Jenkinsfile Lint

CI codecov PyPI version

Catch Jenkinsfile syntax errors before they break your CI.

jenkinsfilelint validates your Declarative Pipeline syntax via Jenkins's /pipeline-model-converter/validate endpoint. 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

Then add the pre-commit hook (see below) or use the CLI directly.

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.

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.

[!IMPORTANT] The pre-built image includes plugins for the most common Declarative Pipeline patterns (see full list). If your production Jenkins has additional plugins (e.g., kubernetes), local mode may still report false positives for those constructs. For full fidelity, use remote mode pointing at your real Jenkins, or build a custom image that mirrors your production plugin set.

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
jenkinsfilelint Jenkinsfile Jenkinsfile.prod tests/Jenkinsfile
jenkinsfilelint --local Jenkinsfile

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 pre-commit too:

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"]

Configuration

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

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

* Not required in --local mode. ** Only required if your Jenkins requires authentication (not used in --local mode).

[!TIP] Even if your Jenkins allows anonymous access for validation, using an API token is recommended for production setups.

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

[!WARNING] Never hardcode credentials in config files — use environment variables.

  • 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 POSTs your Jenkinsfile to Jenkins's /pipeline-model-converter/validate endpoint and reports whether the syntax is valid. That's it — it only answers: "Will Jenkins accept this syntax?"

  • Remote mode: validates against your existing Jenkins server using the URL and credentials you configure.
  • 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.

Requirements

  • Python 3.10+
  • For remote mode: a Jenkins server with the Pipeline plugin installed
  • For --local mode: Docker or Podman

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jenkinsfilelint-1.5.1.tar.gz (148.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jenkinsfilelint-1.5.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file jenkinsfilelint-1.5.1.tar.gz.

File metadata

  • Download URL: jenkinsfilelint-1.5.1.tar.gz
  • Upload date:
  • Size: 148.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for jenkinsfilelint-1.5.1.tar.gz
Algorithm Hash digest
SHA256 a659dc658dbc2a2baf2ea3ab269eeec60f72a06f33d46fc9c834cde86cdfde49
MD5 229d5db727a261509a98c3bc52ac4a46
BLAKE2b-256 0e9be76fc4fc252b860e82dad03e5f09929cd4ed507fbed8f2bf3fa4b47c9577

See more details on using hashes here.

Provenance

The following attestation bundles were made for jenkinsfilelint-1.5.1.tar.gz:

Publisher: release.yml on jenkinsci/jenkinsfilelint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jenkinsfilelint-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: jenkinsfilelint-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for jenkinsfilelint-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 604cfbaa3c41eaf2a32090f44d2ebcaf6b6cbad333407bfc0e14745021659d6f
MD5 20fbcb1f7d3fca890de9f6b1d6e2bffe
BLAKE2b-256 d2e32281c2ac5999a2b2ff02876047bd231ab1d0770d7d18d5c569321e59ef17

See more details on using hashes here.

Provenance

The following attestation bundles were made for jenkinsfilelint-1.5.1-py3-none-any.whl:

Publisher: release.yml on jenkinsci/jenkinsfilelint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.5.1 This release

2 files

1.5.0

2 files

1.4.1

2 files

1.4.0

2 files

1.3.0

1 file

1.2.0

1 file

1.1.0

1 file

0.0.0

1 file

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