Josh M.
Josh M.

Reputation: 27783

Prevent Jenkins from polling SCM (Git) while build is running

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.

Upvotes: 7

Views: 1320

Answers (2)

Josh M.
Josh M.

Reputation: 27783

There is no fix for this issue other than switching to webhook-based builds, which is what we did, and never looked back.

Upvotes: 2

AaronDossett
AaronDossett

Reputation: 21

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.

Upvotes: 1

Related Questions