I wanted to schedule a job in Jenkins to run sometime between 18pm till 2am.
So I entered the following formula in Build periodically/Schedule field:
H H(18-2) * * *
However, when I save the job, there is an exception:
javax.servlet.ServletException: java.lang.IllegalArgumentException: n must be positive
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:719)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:770)
(...)
Caused by: java.lang.IllegalArgumentException: n must be positive
at java.util.Random.nextInt(Unknown Source)
at hudson.scheduler.Hash$1.next(Hash.java:72)
at hudson.scheduler.BaseParser.doHash(BaseParser.java:100)
at hudson.scheduler.CrontabParser.term(CrontabParser.java:328)
at hudson.scheduler.CrontabParser.expr(CrontabParser.java:180)
at hudson.scheduler.CrontabParser.startRule(CrontabParser.java:60)
... 60 more
for testing purposes when I entered:
H H(0-2) * * *
it works fine.
Can you tell me what is wrong?
That doesn't seem to be possible at the moment, take a look at this bug:
https://issues.jenkins-ci.org/browse/JENKINS-18313
My first answer included this suggested workaround, which doesn't work:
H H(18-23,0-2) * * *