In Jenkins, sometimes we may need to trigger multiple jobs in a particular sequence, each performing some unique task. For instance let us consider a scenario, where we have one parent job to perform a maven build of a Java based project. We also have 2 separate child jobs for packaging - let's say one creates a Windows installer and the 2nd one which creates a Linux installer. Now, we want to automatically trigger the packaging jobs immediately after the build is finished. The Parameterized Trigger plugin helps us exactly to achieve the same. Using this, we can chain multiple jobs and pass parameters across them.
Let us consider the above scenario in some more detail.
Firstly, make sure the Parameterized Trigger plugin is installed in Jenkins.
Now, as said above I have one parent job which essentially performs a maven build of a Java based project. Once the build is finished, I want to trigger 2 child jobs - one which creates a Windows package and the other which creates a Linux package. In our case, we have the version 2.31 installed. Latest versions are available periodically.
Now, lets configure the chaining of packaging child job within the parent job i.e Maven build job. While doing so, I want to a bunch of pre-defined parameters across the build. For eg: I want to pass the build version and the location of Clearcase build view. The parameters could be either a constant variable or an environment variable.
Make sure to tick the option "This build is parameterized" and add a few parameters as desired.
Now add a new build step "Trigger/call builds on other projects" from the list.
Now all you have to do is mention the child build that you want to fire and the list of specific pre-defined parameters that you want to pass to it. Check the screenshot below for illustration.
Here we are passing 2 parameters - version and path_loc. Kindly note the syntax. Note that these 2 parameters need to be defined in both the parent and child jobs. In case you do not want to pass all the current build parameters instead of specific ones, simple choose the "Current build parameters" from the "Add Parameter dropdown list."
Alternatively, you could also pass the parameters from a specific properties file as well by specifying its location.
Ciao guys. Drop in your comments for any suggestions, questions or queries please. Grazie!
Let us consider the above scenario in some more detail.
Firstly, make sure the Parameterized Trigger plugin is installed in Jenkins.
Now, lets configure the chaining of packaging child job within the parent job i.e Maven build job. While doing so, I want to a bunch of pre-defined parameters across the build. For eg: I want to pass the build version and the location of Clearcase build view. The parameters could be either a constant variable or an environment variable.
Make sure to tick the option "This build is parameterized" and add a few parameters as desired.
Now add a new build step "Trigger/call builds on other projects" from the list.
Now all you have to do is mention the child build that you want to fire and the list of specific pre-defined parameters that you want to pass to it. Check the screenshot below for illustration.
Ciao guys. Drop in your comments for any suggestions, questions or queries please. Grazie!
No comments:
Post a Comment