Triggering Jenkins jobs from the SCM push to avoid the evil polling

Why?

If you have a continuous integration infrastructure with Jenkins you might have you jobs configured to make polling over your SCM in order to trigger a job when there are changes. But this has some problems when Jenkins has several nodes and there are a big amount of jobs.

In my case, i configured the Jenkins jobs to poll the SCM repository ( Mercurial ) every 5 minutes. What that means?

  • A very big load in the SCM repository server due to the big amount of pollings from every Jenkins job.
  • Unexpected behaviour of the polling due to Jenkins bugs or SCM plugin bugs ( at least in the Mercurial one )
    • Jobs launched with no changes because the polling couldn’t be done because maybe the workspace of the previous build is not available
    • Jobs not launched although there are changes because of the loss of threads that manage the channel connections between the master and the slaves (Jenkins bug)

Continue reading