This gist shows how you can validate Jenkinsfile within Vim :-) but if you don't use Vim, you should be able to use it in a terminal or adapt it to your needs anyway, you can even convert it to a bash function ;-)
It's inspired by the official documentation https://www.jenkins.io/doc/book/pipeline/development/#linter
- Expose your jenkins credentials and instance URLs somehow (environment variables)
JENKINS_URLJENKINS_USERNAMEJENKINS_SECRET(password, or user token...)
- Create somewhere (
~/scripts/checkci.sh?) a script with the proposed content in this gist.- make it executable
chmod +x ~/.scripts/checkci.sh - create a symbolic link to it. example :
ln -snf ~/.scripts/checkci.sh /usr/local/bin/checkci
- make it executable
- It should be enough to allow you to validate Jenkinsfile via the terminal. example:
checkci,checkci Jenkinsfile.acceptance, ...
- Install https://github.com/dense-analysis/ale via the vim plugin manager of your choice, or manually... I suggest you start at https://vimawesome.com/plugin/ale ;)
- Update your
~/.vimrcwith the proposed config - Create
~/.vim/ale_linters/Jenkinsfile/checkci.vimwith the proposed content


So, when I do this - vim is always complaining that:
Which, of course, seems to be true since this example adds a
linterand not afixer? But if I removecheckcifrom the list of fixers forJenkinsfile, of course the linter does not run at all?boggle