Make stuff to do things

Subscribe (?) Subscribe to RSS

Posts Tagged ‘howto’

How-To for github_buildbot.py

Published on July 14th, 2009 in Comments

github_buildbot

GitHub & Buildbot - together at last

github_buildbot.py is a small web server that responds to JSON that is POST’ed to it from GitHub.com and initiates a build on Buildbot instance.  You may find the latest source code at GitHub.

Getting Started

In short:

  1. start github_buildbot.py
  2. add your github_buildbot server url to a post-receive service hook in GitHub (ie: http://example.com:4000)
  3. configure your buildmaster’s master.cfg to point to /tmp/your_project_name.git
  4. commit and enjoy

How it works

  1. Creates a webserver that listens to port 4000
  2. Accepts JSON POSTs from GitHub
  3. Clones a bare repository locally in a specified directory or the system temp directory by default
  4. Submits changesets to Buildmaster to build

How it works: verbose

Start it up

To start github_buildbot.py, locate the source of Buildbot on your buildmaster and change directory to the ./contrib.  Ensure that github_buildbot is executable and then start it by:

1
./github_buildbot.py

By default, github_buildbot.py starts a webserver on port 4000.  This can altered by doing something like:

1
./github_buildbot.py -p 8888

or

1
./github_buildbot.py --port=8888

The local clone

The Buildbot buildmaster requires that the source directory is locally accessible when you configure the master.cfg in the buildmaster.

from buildbot.steps.source import Git
1
2
3
 from buildbot.steps.source import Git
f1 = factory.BuildFactory()
f1.addStep(Git(repourl='/tmp/apparatus.git'))

The default for github_buildbot.py is to create a “mirror” (which in essence, is the same as “bare”) repository in the operating system’s temporary directory.  For example, the /tmp directory in POSIX systems. Putting source code in the /tmp directory isn’t necessarily good for everyone, so further down I will discuss how to specify the directory.  When github_buildbot.py clones the github repository, it will name the local mirror after the name of the project and append ‘.git’ to it.  In our case, the resulting local mirror is ‘apparatus.git’.  Therefore, when configuring the Buildbot, specify the directory (by default the OS temp dir) and project name appended with a ‘.git’

Private or Public?

If you are using a private repository, it is critical that you start github_buildbot.py with a user whose ssh identity matches a contributor on the GitHub repository.

Something different

In order to specify another build directory other than the operating system’s temporary directory (ie: /tmp), you may use the following flag:

1
./github_buildbot.py -d /path/to/dir

or

1
./github_buildbot.py --dir=/path/to/dir

If, for some reason, that the buildmaster is not localhost:9989, you may specify the buildmaster like this:

1
./github_buildbot.py -m HOST:PORT

or

1
./github_buildbot.py --buildmaster=host:port

It is also possible, that you have an alias for github.com in your .ssh/config directory – especially if you have multiple accounts on one machine.  If you need to specify another “location” other than github.com, you can do so like this:

1
./github_buildbot.py -g hostname

or

1
./github_buildbot.py --github=hostname

Configuring GitHub

GitHub has made this dead simple with Service Hooks.  Add the URL to a post-receive service hook, including the port, to the service hooks section in GitHub.

Service Hooks

Service Hooks

Post Receive URLs

Post Receive URLs

Inputing the Post-Receive URLs

Inputing the Post-Receive URLs

Onceyou have the github_buildbot.py web server running and the service hook enabled in GitHub, you may want to test using “Test Hook” in GitHub.  This will send the last few commits to the specified URL.  You can then debug as necessary if there are any issues.

Help Me

If you still need help, probably best to join the #buildbot IRC channel on irc.freenode.net .

Otherwise, you can do this:

1
./github_buildbot.py --help

or

1
./github_buildbot.py -h
--help of github_buildbot.py

--help of github_buildbot.py

However, if you’re feeling lucky, try turning on logging:

1
./github_buildbot.py -L debug

or

1
./github_buildbot.py --level=debug

You can find all log entries in your operating system’s temporary directory with the filename “github_buildbot.log”.  However, if you’d like to configure that, you can do that too!

1
./github_buildbot.py -l /path/to/new_log_file.log

or

1
./github_buildbot.py --log=/path/to/new_log_file.log
Switch to our mobile site