Back to blog

jenkins-lint: Check Jenkinsfiles Offline, Security Included

Xianpeng Shen
Xianpeng Shen
November 30, 2026 ⏱︎ 6 min read

In June I introduced jenkinsfilelint, a pre-commit hook that sends your Jenkinsfile to your Jenkins controller for validation before you commit. It worked, but every check needed a running controller, credentials and a network connection.

Its successor, jenkins-lint, needs none of them. It checks Jenkinsfiles offline, in milliseconds, and also looks for security problems. Version 2.1 is out now.

jenkins-lint reports errors and security findings in a Jenkinsfile, previews the fixes and applies them

Get started

pip install jenkins-lint
jenkins-lint .

There is no Jenkins, Docker or JVM involved. jenkins-lint is written in Rust, and pip installs a prebuilt binary for Linux, macOS and Windows. If you do not use Python, you can download the binary or use the Docker image.

Offline, checked against Jenkins

jenkins-lint parses the Groovy code and checks the Declarative Pipeline structure: agent, stages, environment, options, when, post, matrix and the rest. It shows each error with the code it is about, and words structure errors the way Jenkins does:

error: Not a valid section definition: "agent". Some extra configuration is required.
 --> Jenkinsfile:4:5
  |
4 |     agent
  |     ^

How close is it to Jenkins?

  • 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.

  • In November, I compared it with Jenkins on 17,373 public Jenkinsfiles and shared library steps. It reported no false errors, apart from 11 files where it is stricter on purpose, such as those with a second pipeline block. It missed an error in 6 files. The full results are in the repository.

An offline check cannot know which plugins you have installed, so it does not check step names, step parameters or tools. To check those too, --remote sends the files that pass offline to your own Jenkins:

jenkins-lint --remote https://jenkins.example.com .

Find security problems

Every run also checks for security problems:

  • script-injection: a pull request title, branch name, webhook payload or build parameter that Groovy interpolates into a shell step. Whoever controls the value may be able to run commands on the agent.

  • secret-interpolation: a secret that Groovy interpolates into a shell step, where it can show up in the process arguments.

  • controller-execution: steps that run on the Jenkins controller.

  • unpinned-library: a shared library loaded from a branch.

  • unpinned-image: a container image without a tag, or with latest.

--persona pedantic adds unrestricted-input, for input steps that any user may approve, and other hardening advice.

A value often passes through a variable before it reaches a shell step. jenkins-lint follows it, and shows where it was read (message shortened here):

high[script-injection]: CHANGE_BRANCH is the name of the pull request's branch, ...
  --> Jenkinsfile:10:38
   |
 9 |                     def branch = "${env.CHANGE_BRANCH}"
   |                                   -------------------- CHANGE_BRANCH is read here, into branch
10 |                     sh "git checkout ${branch}"
   |                                      ^^^^^^^^^
   |
   = help: https://jenkinsci.github.io/jenkins-lint/rules/script-injection/

Preview and apply fixes

Some script-injection and secret-interpolation findings can be fixed automatically. The shell then reads the value from the environment, instead of Groovy putting it into the script:

-                    sh "npm publish --token ${TOKEN}"
+                    sh 'npm publish --token "$TOKEN"'

These fixes can change what a pipeline does, so they are only made when you ask for them. Preview them first, then apply them and review the result:

jenkins-lint --diff --unsafe-fixes .
jenkins-lint --fix --unsafe-fixes .

Each finding links to a page that explains the problem and how to fix it. A // jenkins-lint: ignore[rule] comment turns off a finding you have accepted.

Adopt it in an existing repository

A repository with years of Pipelines may have hundreds of findings on the first run. You do not have to fix them all before you start. Write them to a baseline file, and commit it:

jenkins-lint --write-baseline .
git add .jenkins-lint-baseline.json

From then on, only new findings fail the check. Syntax and structure errors are never added to the baseline. After you fix some findings, jenkins-lint --prune-baseline . removes them from the file without adding new ones.

Use it in pre-commit, Jenkins and GitHub Actions

The pre-commit hook needs no credentials:

repos:
  - repo: https://github.com/jenkinsci/jenkins-lint
    rev: v2.1.0
    hooks:
      - id: jenkins-lint

In Jenkins, you can run the Docker image as an agent, with the Docker Pipeline plugin:

pipeline {
    agent {
        docker { image 'ghcr.io/jenkinsci/jenkins-lint:2.1.0' }
    }
    stages {
        stage('Lint') {
            steps {
                sh 'jenkins-lint .'
            }
        }
    }
}

In GitHub Actions, --output-format github shows errors and findings as annotations on the pull request:

- run: pipx run jenkins-lint --output-format github .

--output-format sarif writes a report for GitHub code scanning, or for the Warnings Next Generation plugin in Jenkins.

Moving from jenkinsfilelint

jenkins-lint 2.x is not compatible with jenkinsfilelint 1.x. The package, the command, the repository and the hook are all named jenkins-lint now, and files are checked offline unless you pass --remote. The migration guide lists what replaces each old name and option. jenkinsfilelint stays at 1.7.2 and will not be updated.

Feedback is welcome

The documentation covers all the rules and options. If jenkins-lint reports an error in a file that Jenkins accepts, misses one that Jenkins reports, or gets a security finding wrong, please open an issue.

About the author

Xianpeng Shen

Xianpeng Shen

Xianpeng is a DevOps and Build Engineer and a contributor of the Jenkins GitHub organization. He is the author of Explain Error Plugin, a Jenkins plugin that uses AI to diagnose job failures. In the open-source community, he also maintains cpp-linter, commit-check, conventional-branch and other projects.