Friday, October 10, 2008

How to build Ruby On Rails projects using Hudson





In this guide I'm going to show how to set up a Ruby on Rails project on the Continuous integration server Hudson. I've been using Hudson on Ruby on Rails projects since september and it works really well.



Initial downloads

The following files are needed besides Java (at least 1.5). Get the latest version of all files and notice that the Hudson file has the extension .war and plugins .hpi. This guide assumes that Ruby, Rake and Svnplugin are already installed and working.



* Hudson server application



* Ruby plugin



* Rake

Installation steps

I'm going to install Hudson into c:\Program Files\Hudson.

  1. Copy the hudson.war file to c:\Program Files\Hudson

  2. Start Hudson through "java -DHUDSON_HOME=data -jar hudson.war". Verify that you can access Hudson through http://localhost:8080

  3. Copy the plugins to c:\Program Files\Hudson\data\plugins

  4. Stop Hudson by pressing Ctrl+C in the command prompt where you started Hudson.

  5. Start Hudson again and you should be set to go.

Hudson system configuration

Follow the following steps to configure the tools that Hudson will use in building Your project.

  1. Go to the System configuration at http://localhost:8080/configure.

  1. Click the "New job" link at the home page.

  2. Enter the name "Your project", check the "Build a free-style software project" and press OK.





Source code management

Assumes thata ur project uses a Subversion SCM. Hudson supports CVS and SVN out of the box, but there are many plugins for other SCMs. After checking out the files from the repository Hudson will show the new change sets since the previous build in the Build page. A detailed view of change sets can be seen in the Changes page as the name of the developer, files that were changed and the comment for the change. Each change set is linked to the subversion repository browser, so it is easy to browse the actual file that changed.

  1. Press the Subversion radio button to configure the SCM.


  2. Repository URL=https://xxx.svn.sourceforge.net/svnroot/xxx/trunk/xxx

  3. Local module directory=.

  4. Press the Advanced button

  5. Repository Browser=ViewSVN, URL=http://xxx.svn.sourceforge.net/viewvc/xxx/



To test the configuration, press Save and then Build. The source code will be downloaded from the repository and put into the Workspace. If there were any changes in the SCM repository they can be viewed in the Changes page.





When the build is completed verify that it has checked out the code by going to the Workspace page. Using the Workspace page you can browse and view the files that has been checked out and it doesn't matter if the files are on the master or on a distributed slave!



When the plugin is avalable it detects your ruby instances installed from your PATH but it allows you to add other ruby or jruby paths:



Finally you just need to select the Invoke Rake option into the project configuration and select the tasks that you want to Hudson executes:



That's it, you are ready to go with Rake, Hudson and the Continuous Integration Game.