Press "Enter" to skip to content

Month: May 2017

Validating Jenkinsfile

I had many problems with Jenkinsfiles lately. The syntax is so picky that after a push my plan fails just because I forgot a comma or something as ridiculous as that. In my opinion there are better human input methods for such a file, like yaml. But hey! I’m not developing Jenkins.

Anyway I just integrated a target into my project makefile to test the validity of the Jenkins file. The only way in this case is to send it to your Jenkins server in order to test it like so:

test: jenkins.validate
    @curl -X POST -F "jenkinsfile=<Jenkinsfile" \
    @echo "Jenkinsfile tested."

Is super nice to use the REST API to validate your files but still this has some problems to consider: security (posting to http) or weight of the solution (you need to have a complete Jenkins server in your local host). But that’s not in the scope of this entry.