Push notification from Repository (GIT and Jenkins)

Configure Poll SCM:

When you configure a job in Jenkins, under the option “Build Trigger”, you can see and option Poll SCM.

Jenkins Defines the Option (Poll SCM) as follows.

Configure Jenkins to poll changes in SCM.

Note that this is going to be an expensive operation for CVS, as every polling requires Jenkins to scan the entire workspace and verify it with the server. Consider setting up a “push” trigger to avoid this overhead, as described in this document

Under the schedule box you can put some schedule eg: 0 * * * * (cron string).

This means Jenkins will check if there are any changes every hour and if there are, it will start to build.

This option is already much better than building periodically, which creates a build even if there are no changes in given branch.

Is it Efficient?

Polling a repository from Jenkins is inefficient as it adds delay on the order of minutes before a build starts after a commit is pushed, and it adds additional loads.


It is much better instead to do push-notification from the repository.


  • Make Sure you have Git Plugin (with Jenkins) 1.1.14  or higher
  • Set up post-receive hook with following line
curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>

This will scan all the jobs that’s configured to check out the specified URL, and if they are also configured with polling, it’ll immediately trigger the polling (and if that finds a change worth a build, a build will be triggered in turn.) We require the polling configuration on the job so that we only trigger jobs that are supposed to be kicked from changes in the source tree.

  • Make sure there is POLL SCM scheduled on Jenkins Jobs Configuration.

Test and TroubleShoot

You can test the above url (without curl) on browser if it actually works. make sure you put correct url for jenkins server and correct url for the git repository.

And That is it.




This entry was posted in GIT, Jenkins. Bookmark the permalink.

Comments are closed.