0

I want to schedule periodic build in jenkins which should run once daily at 9 am till a specific day (example, if today is 1st of dec then it should run from 1st to 7th of dec only)

For running every day at 9 am the script is-

H 9 * * *

What should I add to run it till specific date only?

Shashi Kumar Raja
  • 508
  • 1
  • 8
  • 23

1 Answers1

1

Cron expressions support range selectors. For your specific example, you can specify that it should run from the 1st to 7th of december only:

* 9 1-7 12 *

“At 09:00 on every day-of-month from 1 through 7 in December.”

You can easily test your expression here. Since you can't specify the year in a cron expression, you will have to remove trigger manually afterwards.

Pieter Meiresone
  • 1,910
  • 1
  • 22
  • 22
  • Thanks a lot for the answer. The website is really helpful. – Shashi Kumar Raja Nov 29 '17 at 09:23
  • just one more query. What about the transitioning month. Example- from 27th Nov to 3 Dec everyday 9 am – Shashi Kumar Raja Nov 29 '17 at 09:28
  • 1
    You can add multiple cron expressions in jenkins. I don't think you can add it in one expression. So this for this case, you could use `* 9 27-30 11 *` and `* 9 1-7 12 *`. See also this answer here: https://stackoverflow.com/a/44209349/2840115 – Pieter Meiresone Nov 29 '17 at 09:30