Trigger Jenkins build every 2 hours but only if there was a git commit

git, jenkins

Solution

Set jenkins up to use the "Poll SCM" trigger every 2 hours (0 */2 * * *) or something like that

It'll update from git and, if there was a change, trigger a build.

Problem

Here is the problem that I am having - I need to trigger a job build every 2 hours but only if there was a git commit(skip if there was no activity). I can solve them individually but not sure how to solve them together - anybody has any good ideas? The only one I can come up with is a cron job that would check every 2 hours and if there is a git commit during that time, trigger a job manually, but that does not look all that elegant. Any good ideas appreciated.

Original source