This provides a pre-commit hook for jenkinslint via docker. It uses the jflint package to detect issues in your Jenkinsfile.
pre-commit
by convention mounts the user's code at /src
inside the
container. The executable is fed relative path filename arguments. The hook
may make changes to the files as the source is mounted read-write and the
executables are run as the user.
The metadata in hooks.yaml hooks this up:
entry: askulkarni2/jenkinslint /usr/local/bin/run-jflint.sh
language: docker_image
Here jflint
is the executable inside the container and we tell pre-commit
that the language is docker_image
.
Install pre-commit as per instructions at https://pre-commit.com/#install. You'll also need to use at least version 0.10.0 of pre-commit.
Add this to your .pre-commit-config.yaml
in root of your repo:
- repo: https://github.com/askulkarni2/pre-commit-docker-jenkinslint
rev: master
hooks:
- id: docker-jenkinslint
language: docker_image
entry: --entrypoint /usr/local/bin/run-jflint.sh askulkarni2/jenkinslint
files: Jenkinsfile
Install the pre-commit hook.
pre-commit install