Skip to content

aissa-laribi/jklint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages