Do not poll git if job is scheduled

16 views
Skip to first unread message

Stefan Schiffler

unread,
Dec 11, 2015, 3:14:37 AM12/11/15
to Jenkins Users
Hi all,

i have a jenkins job that polls a git repository every 5 minutes. (These facts cannot be changed so please do not answer like increase the poll interval...)
The build time for the job is about 10 minutes. Now if the repository changes a build starts and during the build is running, exactly the same job is scheduled again twice.
So in the end for every change, jenkins runs the job 3 times. If the first run waits in the queue before running, it is even worse...

Is there a way to disable the git repository polling when a job is scheduled and re-enable it after it finished?

thanks for your answers.

Mark Waite

unread,
Dec 11, 2015, 7:23:23 AM12/11/15
to Jenkins Users
Is the second copy of the job triggered by polling or by a hook script which runs on each commit to the git repository?

If the second run of the job is triggered by polling, then I don't know any way to prevent the duplication (though I generally don't see that type of duplication myself).

If the second run of the job is triggered by a hook script, then you may be able to prevent that second job running by not including the "sha1=xxx" argument in the hook script.  I've found that if a "sha1=xxx" argument is included in the hook arguments, then the git plugin schedules a build of that SHA1, whether or not it has already been built.  If the "sha1=xxx" argument is not included in the hook arguments, then the git plugin polls the remote repositories to see if there are any changes and only schedules a build if there are changes which have not been built.

Mark Waite

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9cdfcb6b-9dff-48f1-b003-48abff5b16be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages