Can I make the SCM polling interval for Jenkins randomised

Michael Neale picture Michael Neale · Aug 10, 2012 · Viewed 23.8k times · Source

In most Jenkins' examples the SCM poll value is designated */15 * * * * , ie. poll SCM every 15 minutes. That's fine when you have hundreds of jobs, but not if you have thousands of jobs as it results in thousands of request to the SCM (Subversion in this case) server at 15, 30, 45, and 0 minutes past the hour.

Is there some way to randomize the polling value in Jenkins so as to avoid the above scenario?

On the Jenkins master configuration screen there's a value "Max # of concurrent polling." Should this be set (and to what value) to avoid the above scenario?

Answer

Stephen Connolly picture Stephen Connolly · Aug 10, 2012

Use H instead of * and Jenkins will randomly distribute the polling. Note that at present a good syntax has not been found for a frequency differing from once per hour/day/etc, so

H * * * *

will poll once per hour at a a pre-determined random minute.

H H * * *

will poll once per day at a pre-determined random hour and minute

H H H * *

will poll once per week

0 H * * *

will poll on the hour but once per day at a pre-determined random hour.

Keep in mind that you are allowed multiple cron lines and any will match, so until a good syntax for sub-hour frequency has been settled on, you can get closer (on average) with something like

H * * * *
H * * * *
H * * * *
H * * * *
H * * * *
H * * * *

will give you on average 15 minutes between polling (yes there will be 6 pollings per hour, but that is to give a good chance that at least one polling will fall in each quarter hour)

If you have good suggestions for a syntax distributing within the hour please respond to this thread:

https://groups.google.com/forum/?fromgroups#!jenkinsci-users/VghEjfygWuw/PuIG1o7u1GQJ%5B1-25%5D

Update (April 2013)

Jenkins 1.510 and newer includes a new syntax to allow specifying distributions within the hour