My Jenkins Story: Validating Jenkinsfile Pipelines

Colin But
2 min readApr 10, 2020

If you’re practicing “Pipeline as Code” in Jenkins then you should be constructing your Pipelines in Jenkinsfile and storing it in the root directory of your application project on your Version/Soruce Control System.

I really love the Jenkinsfile and especially the declarative syntax to declare your pipeline stages because it is really simple to use. It is this simplicity which makes me fall in love with it. I just like simple things.

However, writing them can be a pain. Jenkins UI provide a syntax generator for this but I rarely rely on it; as a developer I prefer to write the code myself. But writing the code yourself means it is very hard to ensure you’ve written it correctly free of syntax errors. The groovy-based DSL is very expressive and really cool but comes the pitfall of tedious writing. It can be quite error-prone & time consuming when you’re testing your pipeline code.

For testing, you can use JenkinsPipelineUnit test framework. But prior to that you require the syntax to error free first and for that you require a validator.

Jenkins docs give plenty of methods of validating your pipeline code. Check out: https://jenkins.io/doc/book/pipeline/development/ for more details on all the ways possible.

--

--

Colin But

Writer sharing thoughts on pretty much everything. P.S. I’m a Coffee-Addict ☕ You can support me by buying me a coffee: https://bit.ly/3hQ5M63