It looks like Kohsuke already did some work on this.

https://github.com/jenkinsci/jenkins/commit/a31a186b264cc95776fb5056edea3eef
8df681a7

  -- Dean


On 4/8/12 7:37 PM , "Ryan Campbell" <[email protected]> wrote:

> We would like to slightly randomize the crontabs in Jenkins for
> DEV@Cloud so that when people all set their jobs to run @midnight, we
> don't have thousands of slaves launch.  Instead we want @midnight to
> mean "once a day -- most likely not midnight' and perhaps let people
> use a tag in the comments of a crontab line (like #exactly) if they
> really need a job to run exactly at midnight. But most people don't
> need this.
> 
> Looking at how Crontabs work in Jenkins, I see that the expressions
> are compiled using ANTLR into an array of Longs (and one Int) which
> are used as bit arrays, with each bit specifying that a cron should be
> triggered at that time for a given unit of measure.  Right?
> 
> So we want to do a random circular bit shift on each unit of measure.
> Something like rotateRight(bitarray,rand(UOM_MAX),UOM_MAX) so that
> (say) for the hour unit of measure, we would shuffle around everyone's
> 0x1 @midnight bit randomly, but still preserve any intervals between
> the bits (and hence the "spirit" of the cron).
> 
> What I'm coming to is that I think I need a new extension point to
> make this happen.  I think the ideal signature would look like this:
> 
> @Extension
> public abstract class CronOverrider {
> 
> /** Called when creating the context from a form submission or in readResolve
> public abstract CrontabList override (CrontabList list, Object context);
> }
> 
> This (my approach) also requires an extra constructor of CronTab so
> that you can create them from raw bit arrays instead of having to pass
> in the expressions.
> 
> So I can work up a patch, but wanted to see if people think this is
> stupid for some reason.
> 
> Ryan

Reply via email to