rtyler / jdp

Jenkins Declarative Parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jenkins Declarative Parser

This repository contains an grammar and parser for the Jenkins Declarative Pipeline syntax. It’s for educational and testing purposes :)

CLI

This repository provides the jdp command line utility which can be used for syntax checking a declarative Jenkinsfile:

❯ jdp check data/valid/complex-deployment/Jenkinsfile
Checking: data/valid/complex-deployment/Jenkinsfile
Looks valid! Great work!

Installing

You can download built release binaries from the GitHub Releases or just run cargo install jdp.

Caveats

This parser is not a Groovy syntax parser, and as such any advanced or wacky groovy that is littered around a Jenkinsfile should largely be ignored. This includes the script step which is basically checked to make sure that there is a script { } block, but anything within it is explicitly ignored.

Development

Development of jdp is all driven through the use of cargo, e.g. cargo test.

It’s relatively straightforward to use a local test Jenkins environment to validate the Jenkinsfile located in data/. There is a major caveat in that many files will fail to validate if certain plugins are not installed on the Jenkins.

Once a local Jenkins is created, be sure to set a fixed sshd port in the /configureSecurity view (e.g. 2022).

find data/valid -iname Jenkinsfile -exec ./scripts/declarative-linter {}  \;

About

Jenkins Declarative Parser

License:GNU Lesser General Public License v3.0


Languages

Language:Rust 99.1%Language:Shell 0.9%