Reputation: 6305
I've created a Jenkins job which queries AWS CLI and populates a variable with some data.
It then triggers a downstream project and injects the variable from the parent job to the downstream job as a parameter for a CloudFormation stack creation (the parameter value is the name of the latest RDS snapshot ID).
I wanted to know if it's possible to trigger different downstream projects based on some choice parameter?
For example, let's say that the parent job has a choice parameter setup with different AWS regions.
The user which starts the build will choose the correct region, and then, based on his selection, the downstream project which will be triggered is the one that matches the region.
Is that even possible? (It's a freestyle project by the way)
Upvotes: 0
Views: 1349
Reputation: 3256
2 ways to do.
1 - Use Parameterized Trigger plugin
Create a job with multiple configurations. Set the matrix configuration in the job (this will be the downstream job). I this case the second job (let's call job B) have multiple configurations that match every scenario you want.
In post build choose "Trigger Parameterized build on other project" (in main job, let's call job A). Then "Add Parameter" and "Restric matrix execution to a subset" here your put you var that is the reference of the group of config in job B.
2 Use Conditional Build Step plugin
In build add "Conditional Steps(multiple)". Set "Run?" to string match. In string 1 put the var ($var1) in the string 2 put the word to match (jobB).
In steps to run, choose "Trigger/call builds on other projects"
Upvotes: 2