Let's say I have a build which takes 5 minutes to run, and SCM polling is set to run every 2 minutes (H/2 * * * *
). If a commit is pushed, Jenkins polls and finds changes and starts build #1. After 2 minutes have elapsed and build #1 is still running, Jenkins polls again, finding the same "change" (which is already being built), and it queues build #2.
I have "do not build concurrently" set for the project.
It appears that the "last built revision" is not updated until the build completes. You can imagine, if I queue up 5-10 different projects around the same time, then Jenkins will slow down (running simultaneous builds from different projects), and polling for each of those projects will continue to add another build for the same commit which is already queued or building.
How do I disable polling while the same project is building? (Changing polling to check every 5+ minutes instead is not the proper solution.)
TL;DR I don't want my Jenkins projects to poll while they are already building, or a build is queued.
1 Answer. "Poll SCM" polls the SCM periodically for checking if any changes/ new commits were made and shall build the project if any new commits were pushed since the last build, whereas the "build" shall build the project periodically irrespective to whether or not any changes were made.
Poll SCM periodically polls the SCM to check whether changes were made (i.e. new commits) and builds the project if new commits where pushed since the last build, whereas build periodically builds the project periodically even if nothing has changed.
Fast Remote Polling is a feature that uses a speedy 'git ls-remote ...' command to perform the SCM polling action rather than having to a clone and fetch a local repository. This feature is enabled by default as of versions 2.2+.
There is no fix for this issue other than switching to webhook-based builds, which is what we did, and never looked back.
As of a few years ago the Jenkins project declined to add this feature:
https://issues.jenkins-ci.org/browse/JENKINS-8950 - disable polling if build is running.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With