0

Lets say there is project A which has a checkbox parameter called jobs. In the jobs parameter there are three downstream jobs B, C and D. Now, is it possible that if I select C and D only those two downstream jobs get triggered?

I know I can do it by calling remote API for those two jobs as part of the build step (shell), but I wanted to see if there is an option from downstream jobs itselfs.

Jason
  • 2,246
  • 6
  • 34
  • 53

2 Answers2

0

Is this a freestyle or pipeline job? This is simple in a pipeline job. In a freestyle job, you might be able to use the Conditional Build Step plugin, but I don't know if you can trigger post-build steps with the conditions, or just build steps. You would need to test and see if this lets you check the conditions where you need to.

Rob Hales
  • 5,123
  • 1
  • 21
  • 33
0

I can suggest you configuring a conditional step in job A

You can modify job A with new choice parameters for each job, for example:

  1. name: build_C; choices:yes/no;
  2. add a conditional step (single) in job A with run: execute shell and Builder: Trigger/call builds on other projects
  3. In the run sections with execute shell add a script to check if your parameter build_C is yes or no, for example if [ $build_C == "YES" ]; then exit 0; else exit 1;fi
  4. In the Trigger/call builds on other projects section Projects to build specify your job C

Now when you start the job A with parameters, if you choose build_C as yes - job C will run. If no - job C will be skipped.

hopetds
  • 435
  • 2
  • 6