Setup triggers inside the Jenkins Pipeline flow
/ 2 min read
The time has come, we are going to let our Jenkins Pipeline triggers some external actions with the help of some custom “triggers”.
In my previous story, I talked about the way I’ve had externalize the configuration of my Jenkins Pipeline and I made a promise to write another story about my triggers mechanism. Now that I’ve been triggered on that task 😉 let’s dive into it!
Externalize the configuration of the Jenkins Pipeline flow
Let’s improve our existing jenkinsfile
Because I’m an adept of the DRY (Don’t Repeat Yourself) principle and to simplify the maintainability, I’m going to reuse my previous jenkinsfile and add the mechanism that will fetch our triggers based on the branch being built.
Let’s take a look at that newly updated jenkinsfile:
Ok, now let’s take a look at the core of the mechanism… 😎
I’m not going to go further on the explication since the two scripts are well documented and, so, self-explanatory. As you can see this is providing a lot of flexibility to improve (see example usage comments) the way your pipeline is acting. I’ve already code most of these examples, so let me know in the comments if an article with some coded examples might interest you. (update: take a look at this publication for a concrete example)