Cerberus Continuous Integration for Rails
Posted by tom August 27th, 2006
Continuous Integration (CI) is a way of automating your tests when you check sourcecode into your sourcecode management system (like Subversion). Every check-in will result in all tests being run, after which developers are informed of the outcome of the build/tests. Martin Fowler wrote a nice article on continious integration.
Cerberus is a Ruby based CI system which can also be used with Ruby on Rails. What follows is a little how-to on Cerberus.
UPDATE: Ofcourse it’s Continuous Integration, but me changing the SLUG of this article doesn’t seem like a good plan …
What you need:- Subversion
- Cerberus (We’ll be installing this in a minute) – I used the newly released 0.2.2
- A rails application (depot) which is checked out using SVN on your local machine
Installing Cerberus
First, you have to install Cerberus using: sudo gem install cerberus. This will give you a new command-line option: cerberus.
Adding your depot application to Cerberus
Now add your depot rails application to Cerberus monitoring:cerberus add depot (if depot is the folder of your rails-app)
Besides adding your depot application to the Ceberus monitoring, this also creates a .cerberus folder in your homedirectory. Go there as we’ll need to do some setup.
Configuration
First copyconfig.yml to config.yml.default as it always is useful to have the original somewhere.
Use your favorite editor to change the config.yml to somewhat similar as my config.yml, I only used the mailing publisher:
publisher:
active: mail
mail:
delivery_method: smtp
address: YOUR_MAIL_SERVER
port: 25
domain: YOUR_DOMAIN
user_name: YOUR_USERNAME
password: YOUR_PASSWORD
authentication: login
sender: "'Cerberus Builder' <cerberus@YOUR_DOMAIN>"
Replace YOUR_MAIL_SERVER, YOUR_DOMAIN, YOUR_USERNAME & YOUR_PASSWORD by the appropriate pieces of information.
If you do a ls in the ~/.cerberus/config folder you’ll see a depot.yml, which you’ll need to change to something similar as mine:
---
publisher:
mail:
recipients: YOUR_EMAIL
scm:
type: svn
url: http://svn.cortauri.net/depot/trunk
builder:
rake:
task: migrate test
Again, replace YOUR_EMAIL by the appropriate address.
As you see the idea is to run rake db:migrate for migrations and rake test for all tests.
Running the tests
If you now use cerberus build depot it’ll run rake db:migrate for migrations and rake test for all tests. Next: you’ll get a mail.
Tip
If your sourcecode did not change running cerberus does nothing, so just put cerberus buildall in your cron. This’ll make sure that if you add more projects to cerberus, they’re all monitored. Usually every 15 minutes will do nicely.

Leave a Reply