I’d like to do a series on how to install and configure BuildBot for debian packaging. I know that is probably not the best tool to automate these kind of tasks, since is designed mainly for CI but it worths a try.

In this first post I’ll only consider how to install it in a Python virtual environment (since is entirely written in Python), (very) basic configuration and some minor tweaks like an Apache VHost and similar. The steps are quite similar for every Debian-like OS (our buildserver is a Debian Wheezy). Obviously the packages could also be installed from the official repositories but the virtualenv idea in this case with a separate user is in my opinion more secure and more upgradable in the future.

First thing to consider is to use a separate user for all build tasks, including the reprepro ones. In our case we used a builder user with very limited access (shortly: no sudo).

All virtualenv and sudo has been created into a buildbot folder. So you have to install the python-virtualenv package first.

$: mkdir buildbot
$: virtualenv buildbot
[... creates the virtualenv here ...]
$: source buildbot/bin/activate

The BuildBot tutorial suggests to use easy_install but I rather prefer pip.

(buildbot)$: pip install buildbot
[... lot of stuff here ...]
(buildbot)$: pip install buildbot-slave
[...same...]

Time to create the “master” that will contain the main configuration. This can be done from command line with a simple script the BuildBot package created for us:

(buildbot)$: buildbot create-master master

This will create and copy all the necessary stuff in a folder master/. Assuming you’ve run all the command into the previously created buildbot/ folder you should have such tree:

buildbot/
├── buildbot
└── master

Let’s rename the master/master.cfg.sample to master/master.cfg and start with minimal editing. The biggest part of editing will be done later, for now we only allow a slave to connect to our master.

Let’s edit the line

['slaves'] = [BuildSlave("example-slave", "pass")]

to something little more secure:

['slaves'] = [BuildSlave('slave1', 'ChooseYourPasswordHere')]

Now we can start the buildbot master:

(buildbot)$: buildbot start master

It should print some information while it parses the config file and start the daemon. In any case the log file to check for debugging is into master/twistd.log.

Now let’s install our first (and only, for ArcheOS) slave, on the same server. BuildBot is designed to allow spreading tasks on multiple slaves on multiple servers but as we don’t need such horse-power we can stick with only one slave on the same machine where the master run.

(buildbot)$: buildslave create-slave localhost:9989 slave1 ChooseYourPasswordHere
[... some output here ...]

Syntax is pretty straightforward. The slave should be started and connected to our master. Time to check the web interface on port 8010 (default) to see if is all fine. If you see an ugly website with a top menu all should be ok. Clicking on the “buildslaves” link you should also see your (only) slave connected. On the “waterfall” page instead you have an example “pyflakes” project. This will serve as example to write configuration later and check everything works.

The master and slave processes are in background so we can also leave the shell and go home, but in case we want a way to simply restart them. An init script would be great, so we can find an example on the official BuildBot repository.

The script has to be adapted just to use our virtualenv instead of the standard path for buildbot (both master and slave), but I’ll do that later.

An apache VHost is fundamental for an easy access to the service without using the 8010 port. First you need to create the entry (or entries) in your DNS, like build.example.com. Then activate the proxy and http_proxy mods on your apache installation (if aren’t already active).

You can use this very simple VHost template, be sure to adapt it to your needs:

<VirtualHost *:80>
ServerName build.example.com
ServerAlias build.example.it

ProxyPass        / http://localhost:8010/
ProxyPassReverse / http://localhost:8010/

ErrorLog /var/log/apache2/buildbot_error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/buildbot_access.log combined
</VirtualHost>

Activate it and you can access to your buildbot web interface simply pointing your browser to http://build.example.com