Kohei Nozaki's blog 

How to make a Jenkins job to poll SCM periodically


Posted on Sunday Feb 23, 2014 at 11:11AM in Jenkins


Environment

  • Jenkins 1.551
  • git version 1.8.3.4 (Apple Git-47)
  • OS X 10.9.1

Why need it?

  • As I wrote in How to make git commit to trigger run a Jenkins job, Git plugin of Eclipse doesn't fire hooks.
    • Unfortunately, currently EGit not supported it, and maybe will not[1].
  • So we need an alternative way, such as make Jenkins to poll SCM periodically.
    • It seems to I can configure it easily so I just try it here.

How to configure

  1. Go to configure page of a project.
  2. Go to “Build Triggers” section.
  3. Check “Poll SCM”
  4. Enter the schedule that you want in cron-style.
    • The help that placed side of input area might be useful
    • Example for poll at every 15minutes is here:
  5. Save

See the log

  • When any change is detected at polling, we can see that message in log of Jenkins.
    • In this setup, the log file is located at /var/log/jenkins/jenkins.log
Feb 23, 2014 11:24:45 AM hudson.triggers.SCMTrigger$Runner run
情報: SCM changes detected in BuildAndTestHead. Triggering  #22
Feb 23, 2014 11:24:57 AM hudson.model.Run execute
情報: BuildAndTestHead #22 main build action completed: SUCCESS

Remarks

  • I'm not sure that CPU usage or any other resource consumption of git polling.

References

  1. Eclipse Community Forums: EGit » Enabling hooks in EGit