Regarding the item 2. Use the Parameterized-Trigger plugin ( https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin). This plugin lets you trigger downstream-jobs based on certain triggers. The triggers appear to be too restrictive though. They're all based on the state of the build, not arbitrary variables. I don't see any option provided here that would work for my use case.
There is a pull request to add the functionality of the flexible publish plugin in to it and all the conditions with it. See pull request https://github.com/jenkinsci/parameterized-trigger-plugin/pull/17 Chris On Wednesday, October 31, 2012 10:43:36 PM UTC, benjamin.a.lau wrote: > > You can get a conditional behavior with the Parameterized Trigger > plug-in actually. I have mine set to use a properties file and if the > properties file doesn't exist... the triggered build will not run. > > I manage the creation of the properties file using a shell build step > with the following hunk of code: > if [[ "${parameter}" == "true" ]] > then > cat - > "${WORKSPACE}/trigger.properties" <<XXX > triggered_job_parameter1=value2 > triggered_job_parameter2=value2 > XXX > fi > > Make sure "Trigger build without parameters" is unchecked. > > Ben > > On Wed, Oct 31, 2012 at 3:10 PM, Neerenberg, Aaron > <[email protected] <javascript:>> wrote: > > Nick- > > > > > > > > Not the best, but here’s a thought. > > > > > > > > 1. During your build, evaluate which post build action you would > > like, and echo some sort of semaphore based on that state > > > > 2. Configure 2 post build-steps for your job, each with > conditional > > text from the log file. Conditional text to match is your semaphore > that > > you echo. > > > > 3. Because the parameterized build step won’t allow > conditionality, > > have your post build steps perform a wget or curl call to the URL of the > > downstream jobs to trigger depending on which you want to do. > > > > 4. You will need to modify the downstream jobs to allow remote > > triggering. > > > > -Aaron > > > > > > > > From: [email protected] <javascript:> > > [mailto:[email protected] <javascript:>] On Behalf Of Nick > Martin > > Sent: Wednesday, October 31, 2012 2:55 PM > > To: [email protected] <javascript:> > > Subject: How to conditionally build down-stream projects? > > > > > > > > I have a fairly complicated Jenkins job that builds, unit tests and > packages > > a web application. Depending on the situation, I would like to do > different > > things once this job completes. I have not found a > re-usable/maintainable > > way to do this. Is that really the case or am I missing something? > > > > > > > > The options I would like to have once my complicated job completes: > > > > > > > > 1. Do nothing > > > > > > > > 2. Start my low-risk-change build pipeline: > > > > - copies my WAR file to my artifact repository > > > > - deploys to production > > > > > > > > 3. Start my high-risk-change build pipeline: > > > > - copies my WAR file to my artifact repository > > > > - deploys to test environment > > > > - run acceptance tests > > > > - deploy to production > > > > > > > > I have not found an easy way to do this. The simplest, but not very > > maintainable, approach would be to make three separate jobs, each of > which > > kicks off a downstream build. This approach scares me for a few reasons > > including the fact that changes would have to be made in three places > > instead of one. In addition, many of the downstream jobs are also nearly > > identical. The only difference is which downstream jobs they call. The > > proliferation of jobs seems like it would lead to an un-maintainable > mess. > > > > > > > > I have looked at using several approaches to keep this as one job, but > none > > have worked so far: > > > > > > > > 1. Make the job a multi-configuration project > > (https://wiki.jenkins-ci.org/display/JENKINS/Building+a+matrix+project). > > > This provides a way to inject the job with a parameter. I have not found > a > > way to make the "build other projects" step respond to a parameter. > > > > > > > > 2. Use the Parameterized-Trigger plugin > > ( > https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin). > > > This plugin lets you trigger downstream-jobs based on certain triggers. > The > > triggers appear to be too restrictive though. They're all based on the > state > > of the build, not arbitrary variables. I don't see any option provided > here > > that would work for my use case. > > > > > > > > 3. Use the Flexible Publish plugin > > (https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin). > This > > plugin has the opposite problem as the parameterized-trigger plugin. It > has > > many useful conditions it can check, but it doesn't look like it can > start > > building another project. Its actions are limited to publishing type > > activities. > > > > > > > > 4. Use Flexible Publish + Any Build Step plugin > > (https://wiki.jenkins-ci.org/display/JENKINS/Any+Build+Step+Plugin). > The Any > > Build Step plugin allows making any build action available to the > Flexible > > Publish plugin. While more actions were made available once this plugin > was > > activated, those actions didn't include "build other projects." > > > > > > > > 5. Use the Conditional Build Step plugin > > ( > https://wiki.jenkins-ci.org/display/JENKINS/Conditional+BuildStep+Plugin). > > > This plugin looks like it only lets you create conditional build steps, > not > > conditional *post*-build steps. > > > > > > > > Is there really not an easy way to do this? I'm surprised that I haven't > > found it and even more surprised that I haven't really seen any one else > > trying to do this? Am I doing something unusual? Is there something > obvious > > that I am missing? > > > > > > > > PS I also posted on StackOverflow last week, but didn't get any good > answers > > there. > > > http://stackoverflow.com/questions/13091488/how-to-conditionally-build-other-projects > >
