4

I have a gitPoller set up to run, every 60 seconds, but would rather use the post-commit hook. I am confused on how to accomplish this. I know that I'm supposed to copy the git_buildbot.py file somewhere, but am not sure exactly where.
Also, I don't know what to write for the post-receive file under git hooks.

Tiago Sippert
  • 1,324
  • 7
  • 24
  • 33
TLu
  • 88
  • 8

3 Answers3

2

Assuming that you have your base Git repository (on your Git server) at /var/git/yourproject, then you would install the git_buildbot.py file in /var/git/yourproject/hooks. Once you place the (correctly edited) git_buildbot.py file into that directory, you should chmod 755 git_buildbot.py to make sure that it's executable (assuming that your Git server is some flavor of Unix/Linux.)

Once you have done that and tested it, you should probably turn off the gitPoller on your CI server.

Mike
  • 7,994
  • 5
  • 35
  • 44
  • Thanks for the help, however, I just encountered a new problem in which the post receive script seems unresponsive and the push command never finishes. After a traceback, I found that the program freezes at `line = sys.stdin.readline()` or line 278. Buildbot never receives the notification, or at least, doesn't build after the hook. Help would be greatly appreciated – TLu Jul 09 '13 at 22:08
1

@Tlu: Just for the protocol: I had the same issue and at last I caught myself at installing a client side git hook (in /home/myself/project/.git/hooks like mentioned in in this tutorial ) instead of a server side git hook (which has to lie in somewhere like /srv/git/project/hooks).

So I just accidentally missed to use the right folder because in my buildbot setup both directories where on the same machine and maybe that one bad drink in the bar yesterday ;)

Just a stupid mistake but in case someone runs into the same trap I wanted to let you know.

pat
  • 41
  • 3
1

You could use Buildbot's Change Hooks for this.

Add the poller hook to the www settings in your master.cfg file:

c['www'] = {
    # ...
    'change_hook_dialects': {
        'poller': True,
    },
    # ...
}

Suppose your Git repository is set up in Buildbot like this:

GitPoller(repourl='/path/to/my-project.git',
          project='my-project',
          pollInterval=3600,
          pollAtLaunch=True)

If your Buildbot URL is http://localhost:8010/, then your post-commit hook (.git/hooks/post-commit) can be:

#!/bin/bash

curl -s -F poller="$(pwd)" http://localhost:8010/change_hook/poller

(Make sure that the script is executable: chmod +x post-commit).

This will notify Buildbot to poll the repository immediately after you commit. The script above is also usable as a post-receive hook.

Flux
  • 9,805
  • 5
  • 46
  • 92