jenkins the definitive guide

(Jeff_L) #1

Now go to the Build section of your freestyle project and choose “Execute NAnt build” (see Figure 5.56,
“A build step using NAnt”). Here you specify your build script and the target you want to invoke. If you
click on the “Advanced...” option, you can also set property values to be passed into the NAnt script.


Figure 5.56. A build step using NAnt


5.10.5. Building Projects with Ruby and Ruby on Rails


Jenkins makes an excellent choice when it comes to integrating CI into your Ruby and Ruby on Rails
projects. The Rake Plugin lets you add Rake build steps to your build jobs. You can also use the Ruby
Plugin lets you run Ruby scripts directly in your build job. Finally, the Ruby Metrics Plugin provides
support for Ruby code quality metrics tools such as RCov, Rails stats, and Flog.


Another invaluable tool in this area is CI:Reporter. This library is an add-on to Test::Unit, RSpec,
and Cucumber that generates JUnit-compatible XML reports for your tests. As we will see, JUnit-
compatible test results can be used directly by Jenkins to report on your test results. You would install
CI:Reporter using Gem as illustrated here:


$ sudo gem install ci_reporter
Successfully installed ci_reporter-1.6.4
1 gem installed

Next, you will need to set this up in your Rakefile, by adding the following:


require 'rubygems'
gem 'ci_reporter'
require 'ci/reporter/rake/test_unit' # use this if you're using Test::Unit

In Chapter 9, Code Quality, we discuss integrating code quality metrics into your Jenkins builds. Jenkins
also provides support for code coverage metrics in Ruby. The Ruby Metrics Plugin supports code
coverage metrics using rcov as well as general code statistics with Rails stats. To install the rcov-
plugin, you will first need to run something along the following lines:


$ ./script/plugin install http://svn.codahale.com/rails_rcov

Once this is set up, you will be able to display your test results and test result trend in Jenkins.


Finally, you can configure a Rake build simply by using a Rake build step, as illustrated in Figure 5.57,
“A build step using Rake”.

Free download pdf