How to run parametrized job after another (without params)
Asked Answered
E

1

15

I have a job in Jenkins which has 2 params. I want to run another plan, which has no params and from that plan, launch the existing plan as many times as required.

The new plan needs to be scheduled to run each 15 minutes (will be done by Jenkins' scheduler option), the code of that plan will:

  • connect to a db
  • get required recordset
  • start looping the recordset
    • store the key/value pair (parameters for the existing job)
  • end looping

Once this is done, I need to run the existing job with each key/value pair that was stored. Can I do it like this out of the box with Jenkins (using 1.406) or do I have to call the existing job remotely? I don't see how to pass parameters from one plan to another when using the "Build other projects" option in the "Post-build Actions" section (configuration of a plan)

Thanks

Endocarditis answered 25/7, 2011 at 13:15 Comment(0)
F
18

There is a Parameterized Trigger Plugin which, once installed, allows you to trigger a parameterized build after one build has finished.

The easiest way to accomplish what you want would be to install this plugin, and build the project once with the key/value list that you want to build against. If for some reason you need to execute the build multiple times after the first job completes, then you could use the remote API to start builds from your first project. So you have two options:

Option A

  • Project1 executes, creates a file with key/value pairs
  • Project1 completes, is configured to execute Project2 with parameters (using the Parameterized Trigger Plugin)
  • Project2 loops through the key/value pairs, doing whatever you need to do for each one

Option B

  • Project1 executes. For every key/value pair, it hits the following url http://server/job/<Project2 Name>/buildWithParameters?PARAM1=Value1&PARAM2=Value2 (you will need to substitute in your actual project name and parameter names/values)
  • Project2 takes these parameters and builds as normal, using the parameter values wherever it needs to
Frustration answered 25/7, 2011 at 20:58 Comment(4)
Thanks Laepdjek; I'll give a look at the Parameterized Trigger Plugin ASAPEndocarditis
Thanks you very very much!! (I've searched for buildWithParameters?PARAM1=Value for a long time).Tungting
Can I start two Parameterized Tasks after one successful build of upstream job using Parameterized build plugin ?Whitelivered
Solved above problem by starting dependent tasks only after the first task succeeded. This Way I can have as many dependent tasks as I need.. Thanks any way for suggestion of plugin.. That will certainly come handy in some situations..Whitelivered

© 2022 - 2024 — McMap. All rights reserved.