So if you are like me you’ve been searching the web for how to write Jenkins DSL and you’ve realized this is a larger and more vague task then you realized. Jenkins DSL (Groovy) sucks, make peace with that now and the rest will be easier.  You may have stumbled across the Jenkins DSL Plugin and started messing around, you may have missed (like I did) that there is a DSL Plaground that you can paste your code into and test it out. I went a step beyond that and have since built my own docker container that I can run my code in as I wasn’t 100% happy with posting my code into someone else’s app. I’ll post that docker link when I eventually post the docker container to the repo.

But you’ll eventually hit the roadblock of a plugin not supported by the DSL, this happens fairly quickly and you have to resort to the “configure blog”:

Now the best way to figure this out is to configure the plugin via the Jenkins GUI and then open up the job config.xml and then you can reverse engineer the groovy code.

Unfortunately it’s very much trial and error but using the config.xml + the DSL playground you can get about 75% there and then the rest is just iteration.

Written by kevin