0

How to schedule the parameterized jenkins job?

I have a parameterized parent job which has 6 child jobs. when the parent job is triggered it should start the child jobs one after another.I should run the parent job for every 7 hours on weekend which I have given as H */7 * * 6-7.

My questions are:

  1. How does the parent job takes the parameters when it is triggered?
  2. Does it take the default choice or do i need a script to give the parameters?
  3. How to configure if i want to skip any one of the child job?
Nikita Kniazev
  • 3,728
  • 2
  • 16
  • 30
avi
  • 37
  • 2
  • 8

1 Answers1

0

Use the Parameterized Scheduler Plugin

1) Here's an example of passing parameters via the scheduler. If your job is parameterized, the plugin will add an option "Build periodically with parameters".

H */7 * * 6-7 % Environment=development; Version=2,4,3

2) I don't think it honors a default, I have not seen that in the docs. Let us know if you find something.

3) Via the parameters?

Adam vonNieda
  • 1,635
  • 2
  • 14
  • 22
  • parameterized scheduler plugin is installed 1) but when i give it is showing Invalid input: "H */7 * * 6-7 % TEST_ENV_BRANCH=origin/master;": line 1:14: expecting EOF, found ' ' 2) i was able to trigger my jobs by setting the required parameters as default. 3) I found the answer. I unchecked the child job in the configurations – avi May 30 '19 at 13:43
  • H */7 * * 6-7 % TEST_ENV_BRANCH=origin/master line 1:14: expecting EOF, found when i give this is giving me an error on jenkins – avi Jun 12 '19 at 14:16
  • I wonder if it's not liking the slash "/" that you have in your parameter between origin and master? Just a guess. You might try the parameter without the slash just to see if the error goes away. – Adam vonNieda Jun 12 '19 at 14:22
  • I tried with H */7 * * 6-7 % LINUX=ubuntu but i see the same error expecting EOF – avi Jun 12 '19 at 14:39
  • 3
    I think the problem is that you're choosing "Build periodically" instead of "Build periodically with parameters". – Adam vonNieda Jun 12 '19 at 14:46
  • Do you have parameters defined on your job? The option won't show up unless you do. You should have a parameter defined on your job for each parameter you want to pass. – Adam vonNieda Jun 12 '19 at 14:52
  • yes the parameters are defined in my job and the option this build is parameterized is checked – avi Jun 12 '19 at 14:55
  • Hmm OK good. And you've double checked that you have the "Parameterized Scheduler Plugin" installed, right? – Adam vonNieda Jun 12 '19 at 14:56
  • I'm not sure why the "Build periodically with parameters" option is not showing up for you, sorry. You might want to try one of the IRC channels - https://jenkins.io/chat/ – Adam vonNieda Jun 12 '19 at 15:04