title: How to conditionally build other projects?
body: <p>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?</p>
  
  <p>The options I would like to have once my complicated job completes:</p>
  
  <ol>
  <li><p>Do nothing</p></li>
  <li><p>Start my low-risk-change build pipeline:</p>
  
  <ul>
  <li>copies my WAR file to my artifact repository</li>
  <li>deploys to production</li>
  </ul></li>
  <li><p>Start my high-risk-change build pipeline:</p>
  
  <ul>
  <li>copies my WAR file to my artifact repository</li>
  <li>deploys to test</li>
  <li>run acceptance tests</li>
  <li>deploy to production</li>
  </ul></li>
  </ol>
  
  <p>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.</p>
  
  <p>I have looked at using several approaches to keep this as one job, but none have worked so far:</p>
  
  <ol>
  <li><p>Make the job a multi-configuration project (<a href="https://wiki.jenkins-ci.org/display/JENKINS/Building+a+matrix+project">https://wiki.jenkins-ci.org/display/JENKINS/Building+a+matrix+project</a>). 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.</p></li>
  <li><p>Use the Parameterized-Trigger plugin (<a href="https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin">https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin</a>). 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.</p></li>
  <li><p>Use the Flexible Publish plugin (<a href="https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin">https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin</a>). 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. </p></li>
  <li><p>Use Flexible Publish + Any Build Step plugin (<a href="https://wiki.jenkins-ci.org/display/JENKINS/Any+Build+Step+Plugin">https://wiki.jenkins-ci.org/display/JENKINS/Any+Build+Step+Plugin</a>). 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."</p></li>
  </ol>
  
  <p>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?</p>