Setting up a Hudson Continuous Integration Testing Server for Ruby(and Rails)
August 11, 2010 2 Comments
If you work on a project with multiple developers, a continuous integration testing setup is a must. A CI package will run automated tests on a server on a set(daily) or evented(whenever commits are made) interval.

There are a number of continuous integration packages for Ruby software including CI Joe, CruiseControl.rb. I chose Hudson because it is extendable via plugins and has great support for running automated testing for non-ruby software as well.
Install hudson and jetty:
Hudson itself is a self contained Java servlet. You can either run it in a servlet container like jetty by sticking hudson.war into the webapps directory or just running it using java -jar hudson.war
On your testing server:
Set a working dir:
export HUDSON_HOME=/data/apps/test/hudson
Install ci_reporter:
sudo gem install ci_reporter
Install plugins:
cd /data/apps/test/hudson/plugins
wget http://hudson-ci.org/latest/ruby.hpi
wget http://hudson-ci.org/latest/git.hpi
wget http://hudson-ci.org/latest/rake.hpi
wget http://hudson-ci.org/latest/rubyMetrics.hpi
Setting up a Project in Hudson
We can follow these tasks to create a CI job for a Ruby on Rails 3.0 project.
Hudson will be accessible from http://localhost:8080 or http://localhost:8080/hudson if you used a servlet container.
Click ‘New Job’
Click ‘Build a free-style software project’
This lets you use a custom ruby app.
On the project configuration page:
set the git repo and the option to poll SCM
Add a Execute Shell option with:
bundle install
This will install all the necessary gems from the Gemfile.
Finally, add the rake task for the actual testing itself.
Invoke Rake
ci:setup:testunit
test
CI_REPORTS=results
RAILS_ENV=staging
You can test the setup by clicking the “Build Now” link. In the future, the “Poll SCM” will just run your tests on a set interval whenever code is pushed to your git repo.


