Jenkins Declarative Parser
Go to file
R Tyler Croy e0d13a696c Use a regular expression for a quick sanity check to identify Scripted Pipelines
Fixes #16
2020-12-25 21:48:00 -08:00
.github/workflows Add a simple release action 2020-12-13 16:00:21 -08:00
data Use a regular expression for a quick sanity check to identify Scripted Pipelines 2020-12-25 21:48:00 -08:00
scripts Propagate the nonzero failure status 2020-12-19 12:13:50 -08:00
src Use a regular expression for a quick sanity check to identify Scripted Pipelines 2020-12-25 21:48:00 -08:00
tests cargo fmt 2020-12-13 15:55:25 -08:00
.gitignore Initial commit 2020-12-06 15:06:17 -08:00
Cargo.lock Use a regular expression for a quick sanity check to identify Scripted Pipelines 2020-12-25 21:48:00 -08:00
Cargo.toml Use a regular expression for a quick sanity check to identify Scripted Pipelines 2020-12-25 21:48:00 -08:00
LICENSE.txt Initial commit 2020-12-06 15:06:17 -08:00
README.adoc Some installation instructions 2020-12-19 21:29:11 -08:00

README.adoc

<html lang="en"> <head> </head>

Jenkins Declarative Parser

This repository contains an grammar and parser for the Jenkins Declarative Pipeline syntax. Its 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.

Its 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 {}  \;
</html>