JRuby / Ruby Continuous Integration with Hudson
Hudson is a great tool for your continuous integration needs. It’s very easy to setup and can run/monitor multiple types of tasks. Some have used it for Python and this blog entry will show you how to get Hudson setup quickly for running your Ruby or JRuby tests. (including reporting)
(This step-by-step is assuming you have Java installed on the machine you are using.)
First we’ll need to download Hudson here and start our Hudson instance: (just grab the latest stable release)
java -jar hudson.war
(see Hudson site for other deployment options.)
Next, grab the CI::Reporter gem we’ll need for test results xml formatting :
gem install -y ci_reporter OR for JRuby jruby -S gem install -y ci_reporter
UPDATE: Make sure you insert the following lines in your Rakefile:
require rubygems gem ci_reporter require ci/reporter/rake/test_unit
Hit your running Hudson instance: http://localhost:8080/ and configure a new build by clicking the “New Job” link. Enter the name of your build and select the “Build a free-style software project” (click OK.)
Configure your SCM data, then scroll down to the “Build” section and select either “Execute Windows batch command” (windows) or “Execute shell” (*nix). This is where we’ll call our ‘rake test’ task using the CI::Reporter gem and specifying a spot for the report XMLs to live:
/<your_path>/rake ci:setup:testunit test CI_REPORTS=results OR for JRuby /<your_path>/jruby -S rake ci:setup:testunit test CI_REPORTS=results
UPDATE: When using Subversion, it will check things out into a sub directory of your “workspace” (found ~<user running hudson>/.hudson/jobs/<your job name>/workspace) If you are checking out ‘trunk’ and don’t specify a different name for the directory, your shell execution settings should look like this:
(be sure to know how your SCM works before applying the following)
cd trunk /<your_path>/rake ci:setup:testunit test CI_REPORTS=results
This will setup the CI::Reporter and place the XMLs in the “results” directory for us.
We are almost done, now under the “Post-build Actions” section, check the “Publish JUnit test result report” box and enter the following in the “Test report XMLs” field:
results/*.xml
Now click Save and go test it out… Select your newly created job from the Dashboard.
Click the “Build Now” link… done. After a few builds you should see a graph on the job’s main page that looks like this:

If you have a failure, you can drill down by clicking the “Test Result” link on an individual build’s page.

Clicking on an individual failed test’s name will show you the output from that failure

That’s all it takes, pretty simple and works like a charm. Now you can go back and play with the other settings Hudson has, triggers, scheduling, job artifacts, notifications… you could even have a job that prepares a build by generating all your static content so your server doesn’t have to take the initial hit after startup. (web projects)
If interested, there is a way to create plugins for Hudson.





Sweet post. I think you might have left out:
1. To use CI::Reporter, simply add the following lines to your Rakefile:
require ‘rubygems’
gem ‘ci_reporter’
require ‘ci/reporter/rake/rspec’ # use this if you’re using RSpec
require ‘ci/reporter/rake/test_unit’ # use this if you’re using Test::Unit
http://svn.caldersphere.net/svn/main/ci_reporter/README.txt
Mike said this on January 9th, 2008 at 9:00 pm
Thanks Mike, updated the post…
Mike McKinney said this on January 9th, 2008 at 9:16 pm
Outstanding. Hudson is truly a sweet tool and I’m not at all surprised to see you using it with your Ruby fetish.
Matt said this on January 9th, 2008 at 9:57 pm
Some updates have been made based on comments from Mike Herrick and others using this setup procedure. Let me know if you run into other issues with this post and I’ll update for future reference.
Mike McKinney said this on January 10th, 2008 at 11:36 am
The note about the subfolder when using a SCM does not apply to _all_ scms. But Subversion is one of the SCMs that forces hudson to put the files in a subfolder
Stephen Connolly said this on January 11th, 2008 at 3:55 am
Thanks Stephen, updated.
Mike McKinney said this on January 11th, 2008 at 11:08 am
Excellent post. I hope it would help to set up JRuby’s own Hudson builds system with proper test reports.
Vladimir Sizikov said this on January 15th, 2008 at 5:35 pm
Thanks for this, it works great.
RickMoynihan said this on April 22nd, 2008 at 9:31 am
[...] http://blog.huikau.com/2008/01/09/jruby-ruby-continuous-integration-with-hudson/ [...]
Ruby CI options « Fiji Ecuador Seattle Greece Montana said this on July 10th, 2008 at 6:50 pm
Have you looked at our Parabuild at http://www.viewtier.com/products/parabuild.htm ? It is a bit easier to set up and it provides more extensive statistics.
Alex Pimenov said this on July 11th, 2008 at 2:43 am