A Jenkinsfile linter that validates Jenkinsfiles using Jenkins API
Project description
Jenkinsfile Lint
Catch Jenkinsfile syntax errors before they break your CI.
jenkinsfilelint sends your Jenkinsfiles to your Jenkins server's /pipeline-model-converter/validate endpoint for real syntax validation. It's primarily a pre-commit hook, but also works as a CLI tool.
📖 Read the official blog post for the story behind this tool.
Table of Contents
Quick Start
# .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
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
Usage
Pre-commit Hook
Once installed, every commit that touches a Jenkinsfile is validated:
git commit -m "Update Jenkinsfile"
jenkinsfilelint..........................................................Passed
If the file has a syntax error the commit is blocked:
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, re-commit, and it passes.
CLI
pip install jenkinsfilelint
jenkinsfilelint Jenkinsfile
jenkinsfilelint Jenkinsfile Jenkinsfile.prod tests/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 * |
* Only required if your Jenkins requires authentication.
[!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.
Security
[!WARNING] Never hardcode credentials in config files — use environment variables.
- Never put
--tokenor--usernamein.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 is a syntax gate — it checks that your Declarative Pipeline syntax is valid.
- Reads the local Jenkinsfile.
- POSTs it to
<JENKINS_URL>/pipeline-model-converter/validate. - Jenkins parses the Pipeline and returns
"ok"or errors. - Errors are printed and the tool exits non-zero.
It only answers: "Will Jenkins accept this syntax?"
Requirements
- Python 3.10+
- Jenkins server with the Pipeline plugin
Contributing
See CONTRIBUTING.md.
License
MIT — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jenkinsfilelint-1.4.1.tar.gz.
File metadata
- Download URL: jenkinsfilelint-1.4.1.tar.gz
- Upload date:
- Size: 131.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2998260d447ca3ea1c00ab5fac5f90b2ee00023b4e26eddff2d44e40e53182e
|
|
| MD5 |
36b62bd64750356595a9d5fbb9cf2c36
|
|
| BLAKE2b-256 |
dc40c21bb3721a2cf8f9aba9df693ac718b0b77a2226d80fdde4dab737c0ad38
|
Provenance
The following attestation bundles were made for jenkinsfilelint-1.4.1.tar.gz:
Publisher:
release.yml on jenkinsci/jenkinsfilelint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jenkinsfilelint-1.4.1.tar.gz -
Subject digest:
c2998260d447ca3ea1c00ab5fac5f90b2ee00023b4e26eddff2d44e40e53182e - Sigstore transparency entry: 1769047857
- Sigstore integration time:
-
Permalink:
jenkinsci/jenkinsfilelint@fee2486121bb1a0370a10fab974e46cadbc77284 -
Branch / Tag:
refs/tags/1.4.1 - Owner: https://github.com/jenkinsci
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fee2486121bb1a0370a10fab974e46cadbc77284 -
Trigger Event:
release
-
Statement type:
File details
Details for the file jenkinsfilelint-1.4.1-py3-none-any.whl.
File metadata
- Download URL: jenkinsfilelint-1.4.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c247667328f74b7916c49da2676767b964b4358b2aa3f8cc593f13a04636844a
|
|
| MD5 |
15518ef59bf40f6a00d88b499a519c34
|
|
| BLAKE2b-256 |
f28f7b09f3fdd0e589bb2c1845793b1626e41b128d5a35de5c777abce1dbeb23
|
Provenance
The following attestation bundles were made for jenkinsfilelint-1.4.1-py3-none-any.whl:
Publisher:
release.yml on jenkinsci/jenkinsfilelint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jenkinsfilelint-1.4.1-py3-none-any.whl -
Subject digest:
c247667328f74b7916c49da2676767b964b4358b2aa3f8cc593f13a04636844a - Sigstore transparency entry: 1769048036
- Sigstore integration time:
-
Permalink:
jenkinsci/jenkinsfilelint@fee2486121bb1a0370a10fab974e46cadbc77284 -
Branch / Tag:
refs/tags/1.4.1 - Owner: https://github.com/jenkinsci
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fee2486121bb1a0370a10fab974e46cadbc77284 -
Trigger Event:
release
-
Statement type: