-
Bug
-
Resolution: Unresolved
-
Minor
-
None
We have a job with "Poll SCM" running on `* * * * *` (every minute). We need to use "Included Regions" so the local polling strategy is used. The build takes about 30 minutes. It correctly ignores changes in the steady state but when a commit comes in, it correctly notices a change saying something like:
[poll] Last Built Revision: Revision 50fc7882752856ac86b0838fdf878897e17955cd (refs/remotes/origin/master) Done. Took 6 ms Changes found
and starts the build. But then 1 minute later, it notices the same thing and starts another build. These new builds continue to be started until one of them finishes and then the queueing stops.
I've tried all sorts of combinations to try and get new jobs to not start with the exact same SHA but to no avail. The closest I can get is to let only 1 concurrent build go at a time, but that still leaves 1 job in the queue and we end up double building everything.
Is there a way to have the SCM polling take into account existing builds?
I'm not aware of any way to have git plugin polling account for running builds. As far as I know, it accounts for completed builds, but not for running builds.
Best choice is to not poll. Refer to Kohsuke's blog post for a much less resource intensive solution that avoids polling. Even better is to use web hooks from the git provider. GitHub, Bitbucket, GitLab, and Gitea all provide web hooks.
Second best choice is to poll no more often than the build duration (assuming you do not want concurrent builds running).
Third best choice is to disable concurrent builds. That is the default with Freestyle jobs and can be enabled with declarative pipeline using disableConcurrentBuilds option and can be enabled with scripted pipeline using the disableConcurrentBuilds property.