X

Follow us on Facebook

Trigger Release Builds on Other Projects Using Jenkins


Let us assume ProjectB is dependent on ProjectA and both project releases have to happen in parallel, when performing Release Build it is mandatory that ProjectA is released first and ProjectB later.


In Jenkins, we have options of performing release build separately - first on ProjectA and then on ProjectB. Or triggering release build of ProjectB from ProjectA by using the option "Trigger / call builds on other projects" - this option is quick as it eliminates releasing each project separately.


Step 1: Jenkins configuration of release build on ProjectA



Step 2: If we are using Maven, maven release plugin configuration

 


An important point to note here is usage of underscores in variables: Unix allows only alphanumeric or underscores (Purpose for not using dot (period) is listed in step 5 below)

Step 3: On project B's pom.xml too have similar release plugin configuration as in Step 2 (remember not to use dots in variable names)

Step 4: In ProjectA's jenkins configure "Trigger/call builds on other prjects"




 We use Predefined parameters section to pass parameters from ProjectA to ProjectB. PASS_ON_PARAM is a String parameter configured in ProjectB's Jenkins as shown below


Step 5: In ProjectB, configure the Build options as below



Note above that we are using the PASS_ON_PARAM variable which has all JVM arguments that we passed from ProjectA. If needed, we can add more JVM arguments as required by ProjectA or ProjectB.

Jenkins trigger happens using Unix bash - since bash shell accepts only alphanumeric and underscore caharcters, we cannot have dots in variable names. For example -Dscm.user={scm.user} will not translate the scm.user varible declared in projectA. So better user scm_user as variable name in Jenkin's property declarations as well as in maven release plugin in pom.xml

Step 6: Now we can trigger the release build on ProjectA, this would inturn perform a release build on ProjectB automatically (this happens due to release:prepare release:perform in PASS_ON_PARAM declaration in Trigger section of ProjectA)

You can control the release versions on ProjectB to differ that of ProjectA by using version numbering in PASS_ON_PARAM rather than using {project_releaseVersion}

If you notice some errors while performing release build with wrong version numbers in console, it might be due to errors while Jenkins checkouts SVN/ other source control repositories while preparing build. If you are using SVN, in Jenkin's project configuration you can opt for "Always Checkout Frash Copy"



Or select "Wipe out workspace" as below

 
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment