Skip to main content

A CLI designed to save time linting and validating Jenkinsfiles.

Project description

Jklint

A Jenkinsfile linter CLI saving time linting Jenkinsfiles by only typing 1 argument in the command line.

Features ⭐

1.Credentials entered one time only

2.Short commands to type

3.Validate Jenkinsfiles through the Jenkins Client of your server

4.Masked credentials

Setup 🛠

Jklint can be installed through Pypi or a clone of the repository.

From Pypi

The easiest option to setup Jklint is to install the pip package and run it into a virtual environment.

1.Create a virtual environment

python3 -m venv <virtual-environment-name>

2.Activate the virtual environment

Platform

Shell

Command to activate virtual environment

POSIX

bash/zsh

$ source <venv>/bin/activate

fish

$ source <venv>/bin/activate.fish

csh/tcsh

$ source <venv>/bin/activate.csh

PowerShell

$ <venv>/bin/Activate.ps1

Windows

cmd.exe

C:\> <venv>\Scripts\activate.bat

PowerShell

PS C:\> <venv>\Scripts\Activate.ps1

3.Install the package

python3 pip install jklint

Through clone

1.Clone the repository

git clone https://github.com/aissa-laribi/jklint

2.Create a virtual environment

python3 -m venv <virtual-environment-name>

3.Activate the virtual environment

Platform

Shell

Command to activate virtual environment

POSIX

bash/zsh

$ source <venv>/bin/activate

fish

$ source <venv>/bin/activate.fish

csh/tcsh

$ source <venv>/bin/activate.csh

PowerShell

$ <venv>/bin/Activate.ps1

Windows

cmd.exe

C:\> <venv>\Scripts\activate.bat

PowerShell

PS C:\> <venv>\Scripts\Activate.ps1

4.Install dependancies and package locally

pip install -e .

Usage

It's recommended to run jklint from a virtual environment, this way the credentials and the Jenkins client will not be found in the repository. Only the Jenkinsfile should be in the repository.

1.Configure jklint

jklint config

If you work with VS Code and your OS is a POSIX OS, an .env file should open. Otherwise, find the .env file in your current directory(that should your virtual environment directory)

Replace the values with yours and save the file.

2.Validate the file

jklint go

It will download the Jenkins client from your Jenkins url. Then, it will proceed to the validation of the Jenkinsfile

If the credentials and the syntax of the Jenkinsfile are correct it should return:

Jenkins-client found
CompletedProcess(args=['java', '-jar', 'jenkins-cli.jar', '-s', 'jenkins-url', '-webSocket', '-auth', 'user', 'declarative-linter'], returncode=0, stdout='Jenkinsfile successfully validated.\n', stderr='')

And your 'user' and 'jenkins-url' details will stay hidden.

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

jklint-0.0.2.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

jklint-0.0.2-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

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