William Notowidagdo Kiranatama Staff
Knowledge


I assume you are using Ubuntu and already install Hudson via apt-get. Also you already have rvm configured. First let's install the rvm prequisites
$ sudo apt-get install curl bison build-essential zlib1g-dev libssl-dev libreadline5-dev libxml2-dev git-core
Because I will use ruby 1.8.7, 1.9.2 and ree, so I install the following dependencies
$ sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
Login as the Hudson user
$ sudo -Hiu hudson
Add this ~/.bash_profile
$ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Install rubies that you need
$ rvm install ree,1.9.2,1.8.7
Add the following lines to ~/.rvmrc
rvm_install_on_use_flag=1
rvm_project_rvmrc=1
rvm_gemset_create_on_use_flag=1
I'm a happy Bundler user and you should too. Install gem bundler in every rubies you'll use as a global gem.
$ rvm gemset use 1.9.2@global
$ gem install bundler
Now add your rails project as a job on Hudson. Remember to choose "Build a free-style software project". Add a build step, select "Execute shell" and add the following lines
#!/bin/bash -x
# Environment setup
source "$HOME/.rvm/scripts/rvm"
# Use the correct ruby
rvm use "ruby@gemset"

# Do any setup
# e.g. possibly do 'rake db:migrate db:test:prepare' here
bundle install

# Finally, run your tests
rake
Change ruby@gemset with your ruby and gemset name, e.g.: 1.9.2@awesome-app