Can I restrict the SCM poll work to run only once a day?


I have a poll SCM job , which polls every 5 minutes for a change in Perforce. But I need the job to be triggered only when first edit happens for the files in perforce in a day. Can I restrict poll SCM job to be run only once in a day?

Jenkins itself does not provide this kind of behaviour ("run only for the very first change every day").

You need to split this down into two parts; the first one polling SCM, the second taking care that the job will not run more than once per day.

Possible solution:

  • Keep your current polling job, checking for changes every 5 minutes
  • add a build step that will disable the job after running (thus preventing a second run on this day)
  • create another job that (re-)enables the polling job every morning at 0:00, so the polling job can run upon the next change

If you don't like to see the polling job going into "disabled" state, then you could also remove the job's SCM polling from the job configuration at the end of the run, and have the second job re-establish that. This is a bit more complicated as you need to modify the job configuration.

In any case, "change" will always refer to the last run of the polling job. So if there's two changes A and B on day 1, then the polling job will run once for "A" on day 1, and then immediately again for "B" on day 2.