Wednesday, January 9, 2008

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)
[sourcecode language='css']
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 :
[sourcecode language='css']
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:
[sourcecode language='ruby']
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:
[sourcecode language='css']
//rake ci:setup:testunit test CI_REPORTS=results
OR for JRuby
//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)
[sourcecode language='ruby']
cd trunk
//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:
[sourcecode language='css']

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.


Mike said...

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

Mike McKinney said...

Thanks Mike, updated the post...

Matt said...

Outstanding. Hudson is truly a sweet tool and I'm not at all surprised to see you using it with your Ruby fetish. ;-)

Mike McKinney said...

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.

Stephen Connolly said...

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

Mike McKinney said...

Thanks Stephen, updated.

Vladimir Sizikov said...

Excellent post. I hope it would help to set up JRuby's own Hudson builds system with proper test reports.

RickMoynihan said...

Thanks for this, it works great.

Tom C said...

When attempting to run the rake command, it tries to run the tests but eventually stops with an error along the lines of "could not find/load file" and some messages about ActiveSupport, etc.

It seems that the 1.5.1 version of CI::Reporter claims to have fixed a similar error.

I'm running JRuby 1.1.3 and also tried 1.1.4 but with the same result.

Manipriyan said...

Thanks for sharing

AWS Training in Chennai

Blueprism Training in Chennai

Uipath Training in Chennai

Rathinam said...

Well, do! recently I saw your pretty post and It is good with useful details. Thank you...
Placement Training in Chennai
Best placement Training institutes in Chennai
Power BI Training in Chennai
Job Openings in Chennai
Pega Training in Chennai
Soft Skills Training in Chennai
JMeter Training in Chennai
Tableau Training in Chennai
Appium Training in Chennai
Placement Training in Porur
Placement Training in Anna Nagar

zuan said...

Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!
Web Designing Training Institute in Chennai | web design training class in chennai | web designing course in chennai with placement
Mobile Application Development Courses in chennai
Data Science Training in Chennai | Data Science courses in Chennai
Professional packers and movers in chennai | PDY Packers | Household Goods Shifting
Web Designing Training Institute in Chennai | Web Designing courses in Chennai
Google ads services | Google Ads Management agency
Web Designing Course in Chennai | Web Designing Training in Chennai

Anurag Srivastava said...

These blog concepts are new and unique it is easy to understand compared to other blogs. Keep updating this blogs...Sarkari Jobs 2020 including SSC, Banking Jobs, Railway Jobs, UPSC/Civil Jobs are provided. Sarkari result adda has complete information about all Sarkari Job

Ashok said...

Good to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long. I will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share.
data science course in India

veeraraj said...

Thank you, its really helpful for me.

visit : Digital MarketingTraining in Chennai

Banumadhu said...

Useful article which was very helpful. also interesting and contains good information.
to know about python training course , use the below link.

Python Training in chennai

Python Course in chennai

rajmohan1140 said...

Thanks for this post. I really like your point of view. The blog gives informative content and new users can user observe.

Java Training in Chennai

Java Course in Chennai

Howell Daniel said...

FOXZ88.NET online casino website Global standard 2020-2021

Betting online gambling reminiscent of UFASCR.COM Baccarat.

UFABET football betting website, the big brother of all UEFA networks, UFADNA, with an update The first modern system in 2021

Web football i99PRO online lottery casino apply today for free 5000 bonus

Kardinal Stick Siam - Relx a great promotion. Express delivery in 3 hours.

Howell Daniel said...

FOXZ88.NET online casino website Global standard 2020-2021

Betting online gambling reminiscent of UFASCR.COM Baccarat.

UFABET football betting website, the big brother of all UEFA networks, UFADNA, with an update The first modern system in 2021

Web football i99PRO online lottery casino apply today for free 5000 bonus

Kardinal Stick Siam - Relx a great promotion. Express delivery in 3 hours.

thomas said...

Movie-watching websites that are more than movie-watching websites Because we are the number 1 free movie site in Thailand for a long time, including new movies, Thai movies, Western movies, Asian movies, we have all kinds of ways for you Including new series Full of all stories without interstitial ads to keep annoying anymore. One place

Android and IOS operating systems. Watch online movies, Thai movies, Western movies, Asian movies, Cartoon movies, Netflix Movie, Action Movies, Comedy Movies, Crime Movies, Drama Movies, Horror Movies, Adventure Movies, Crash Movies and still have many new movies to watch. You can watch for free anytime, anywhere 24 hours a day at

GangManga read manga, read manga, read manga online for free, fast loading, clear images in HD quality, all titles, anywhere, anytime, on mobile, tablet, computer. Android and IOS operating systems. Read top comics, action dramas, comedy, adventure, horror and manga. New coming every day to watch many more. Can be read for free anytime anywhere 24 hours a day at

It is no secret that football is among the most popular and widely watched sports. Everybody who likes football tries to find the best platform for free soccer streaming. So, what are the best free sports streaming sites? We are going to answer this question. On this page, you can find a detailed overview of the most widespread soccer streaming websites. Keep on reading and make the best choice for you

Michael L Catudal said...

a fast Online football betting Online casinos Baccarat online In an easy fashion, i99PRO 24-hour service can enable you to pleasantly bet on boxing. And in addition boasts a total service Open just one site, it could do all that. As the center wants actually There's also a Call Center staff members that are manufactured 24 hours 1 day plus the site of ours is a wide choice of expert services including internet football betting. Boxing betting on the internet and casinos that can be starting to be famous in this dimensions. And still popular as among the top. Our i99PRO site in addition has garnered the confidence and total satisfaction of many gambling enthusiasts. And in addition offers a wide choice of football, lottery, basketball, boxing, internet casinos And there are a lot more additional sorts of sports awaiting one to come in.ilver fox

UFABET1688 said...

This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. Check this site: บาคาร่าออนไลน์

Edison hope said...

Wonderful post. Thanks. (Turkey e Visa) Online website method for two main categories of travellers, business travellers, tourist travellers, select your categories & simple online fill visa application form Turkey.

Tom said...

Great post. Thank you The international travelers traveling to Kenya need to check the Kenya online visa application information online. However, the online visa application offers you the best, fastest online visa services. Thank you

kevin said...

Thanks for sharing this information, Keep it up.... Types of South African Visas you can check online via South Africa website, The Government of South Africa has confirmed that South Africa's new e-Visa system will be implemented for 15 countries by March 2022.

Deniel Alex said...

Amazing post…. Travelers from around 169 countries can now apply for an online Indian visa application with 1 month, 5 years validity of 1 year.Travelers can opt for double or multiple entry, depending on the validity of the visa.

jacobalexander said...

I thought I had been to this site before, but when I read some of the posts, I realized it's new to me. Anyhow, I'm glad I found it and I'll be back often. Indian visa for US citizens, If you wish to travel to India, you can apply for Indian visa from USA via Online E-visa India portal.

Albert said...

Good morning everybody.. Your article is more useful for all the people. Thank you sir.. Many people query What is Indian visa service fee? Visa fee depends on your nationality and your visa duration. You can read all other information about the Indian e-visa on our India eVisa page. We have explained all requirement on our page....

dennishcaraid said...

Nice article, inspiring thanks. Citizens of the United States of America need a visa to travel to India. Yes, India visa for US citizens, US citizens can apply online for an Indian visa. Indian visa for US citizens are issued for under the following 5 categories:- You can choose your category then apply for your visa.

Heilaya Kutreeki said...

How wonderful your information is very detailed and useful for me, thanks for sharing. I just inform you, We provide eCommerce web development company services. We aim at making e-commerce solutions technically impeccable and catchy to let your company stand out in the eCommerce market. If you have any query related to ecommerce development solutions then visit our website you will get complete information related to your query.

Bralin Allison said...

I read your blog and found many interesting metrics in this material. Thanks for sharing it on the Internet. Person who is willing to visit Turkey can apply for a Turkey e visa which is a totally online process. Fill the application form, make payment & receive it in email. As simple as that.

Heilaya Kutreeki said...

Wow you have nice content on your page. Your audience will enjoy it while they are read. Turkey visitors can apply for an electronic visa Turkey online from anywhere in the world. The process is easy and convenient which saves your time & money.