2

I've read the help in Jenkins itself and also How to schedule jobs in Jenkins?.

In Jenkins you can build a job periodically by defining a cron like syntax with the addition of H(for "hash").

So defining

H H(0-7) * * *

means build once between 0:00 AM and 7:00 AM.

But how can I define 1 job between 20:00 PM and 7:00 AM of the next day?

Is there any way?

I tried doing

H H(20-23) * * *
H H(0-7) * * *

but ofcourse this will build two times.

Is there any possibility to make it only build once but within this time frame?

derHugo
  • 83,094
  • 9
  • 75
  • 115
  • This has been answered in https://stackoverflow.com/questions/17195208/schedule-nightly-22-03-build-using-jenkins-and-h-the-hash-symbol/55863237#55863237 – Andi May 29 '19 at 07:45

1 Answers1

1

Not exactly an answer but a workarround:

A possible workaround could be to simply use a shifted timezone as e.g.

My Server has Timezone MEZ which equals GMT+1

so I could probably use something like

TZ=Etc/GMT+6
H H(13-23) * * *

this will run the build between 8:00 PM and 7:00 AM of the next day.

derHugo
  • 83,094
  • 9
  • 75
  • 115
  • If you need to set a GMT-XX timezone, this won't work right now, because of JENKINS-57702, see https://stackoverflow.com/a/55863237/1847187 – Andi May 29 '19 at 07:43
  • I don't know, worked fine for me for the last two years .. now we are not using Jenkins anymore.. – derHugo May 29 '19 at 09:52