Skip to main content

A Jenkinsfile linter that validates Jenkinsfiles using Jenkins API

Project description

Jenkinsfile Lint

CI codecov

A Python-based Jenkinsfile linter that validates Jenkinsfiles using Jenkins API.

Contents

Features

  • Validates Jenkinsfiles using Jenkins REST API
  • Works as a pre-commit hook
  • Supports both command-line usage and environment variables for configuration
  • Requires Jenkins credentials for validation

Installation

Using pip

pip install jenkinsfilelint

Using pre-commit

Add this to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/shenxianpeng/jenkinsfilelint
    rev: # or specific version tag
    hooks:
      - id: jenkinsfilelint

Usage

[!IMPORTANT] jenkinsfilelint requires Jenkins credentials to be set via environment variables for validation:

  • JENKINS_URL: Your Jenkins server URL (required)
  • JENKINS_USER: Your Jenkins username (required unless anonymous access is enabled)
  • JENKINS_TOKEN: Your Jenkins API token (required unless anonymous access is enabled)

Command Line

Validation requires Jenkins credentials. Set them using environment variables:

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

jenkinsfilelint path/to/Jenkinsfile

Or using command-line arguments:

jenkinsfilelint path/to/Jenkinsfile \
  --jenkins-url https://your-jenkins-instance.com \
  --username your-username \
  --token your-api-token

Validate multiple files:

jenkinsfilelint Jenkinsfile Jenkinsfile.prod tests/Jenkinsfile

Pre-commit Hook

Create or update .pre-commit-config.yaml in your repository:

repos:
  - repo: https://github.com/shenxianpeng/jenkinsfilelint
    rev: # or specific version tag
    hooks:
      - id: jenkinsfilelint

Then install the pre-commit hook:

pre-commit install

How It Works

The linter sends the Jenkinsfile to your Jenkins instance's /pipeline-model-converter/validate endpoint for validation. Jenkins credentials (URL, username, and API token) are required.

Requirements

  • Python 3.6+
  • Jenkins server with Pipeline plugin installed

License

MIT 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

jenkinsfilelint-1.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for jenkinsfilelint-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88f14bd5e7e7acb876dbe54b36e7a1731504c6aadc81d39b3dc1a087d52cd3da
MD5 6bcef9c1dbae7cb2cb8fd52ae6f80bda
BLAKE2b-256 d6faf2e0e093f477c7b113e956b45a3c0cdb5b1110c64c6691567efb8baebe24

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page