dbr
dbr

Reputation: 169673

Have buildbot poll a git repository for new commits?

Is there a buildbot plugin that will poll a git repository for new commits, like the currently included changes.SVNPoller?

The closest I have found is git_buildbot.py, but it works as a post-commit hook, so will not work with my setup (using Github, and buildbot on a machine that github's post-commit cannot reach) - simply polling the git repository would work perfectly.

I currently have a build run once an hour, but there's not really any point in running the tests unless something has changed..

Upvotes: 8

Views: 5495

Answers (3)

jtomson
jtomson

Reputation: 456

Update: The kind folks at the Buildbot project have made the GitPoller an official Change Source as of version 0.8.2, and made several improvements to the original.


Our company is in a similar situation where our build machines cannot be reached by GitHub's post-commit hook. I've written a GitPoller change source that can be used like the SVNPoller.

It can be found here: http://github.com/wimba/buildbot/blob/master/buildbot/changes/gitpoller.py

and used like this:

from buildbot.changes.gitpoller import GitPoller
c['change_source'] = GitPoller('[email protected]:foobaz/myrepo.git',
                               branch='great_new_feature')

It will create a local repo to work out of (location configurable), and it's only been tested with git 1.7 so your mileage may vary.

Hopefully it will be pulled into the Buildbot project proper at some point, but it's been working for us so far and hoping it may be of use to others :)

Upvotes: 9

Russell Gallop
Russell Gallop

Reputation: 1699

I like the gitpoller.py approach but at the moment I found it a bit limited (e.g. does not send revisions, project arguments) so found a different solution:

I have my own repository cloned from the remote and git_buildbot.py called by the post-merge hook (as described in git_buildbot.py). I have a small loop sleeping and git pulling in that repo which will trigger the post-merge hook.

Upvotes: 0

Pat Notz
Pat Notz

Reputation: 214426

I've not played with buildbot at all but couldn't you do a git fetch and then look at the output of git log master..origin/master? If there are no new commits then the output will be empty (there are, of course, a ton of other options you can use on git log). If there are new commits then just do a git merge and start your build/test cycle.

Upvotes: 1

Related Questions