Install CI Hudson for Ruby on Ubuntu

Posted by AllenWei | Posted in Agile | Posted on 15-02-2010-05-2008

View Comments




<brfore switch to Hudson, we use CruiseControl.rb Compare to CruiseControl.rb, these features is what I favourite
  • We can easily kill or start a new build
  • We can test all branches or some branches in a git repository. It’s
  • It will send email to a mail list when test broke and send another email to someone who break the test.
  • It has code coverage plugin.

Then how to install on ubuntu

Add Hudson source to ubuntu

wget -O - http://hudson-ci.org/debian/hudson-ci.org.key | sudo apt-key add -

Add These line to /etc/apt/sources.list

deb http://hudson-ci.org/debian binary/

Install Hudson

sudo apt-get update
sudo apt-get install hudson

Start is easy

sudo /etc/init.d/hudson start

Configuration

Now you can enter with

your_server_url:8080

Install Hudson Plugin

Go to

Manage Hudson > Manage Plugins > Available

These plugins you need to install

  • Rake
  • Ruby Plugin
  • Ruby metrics plugin
  • Git Plugin (optional)

Create a new Hudson Job

  • Click New Job link
  • Enter your Job name
  • Select Build a free-style software project
  • Setup Git repository
    • Enter Your URL of repository
    • Branch Specifier, if you only want to test master you can type in */master, leave blank hudson will test all your branches

Ok, Save. We leave other configuration for now. we will back.

Click Build Now link at left. Hudson will clone your repository to it’s workspace.
If everything is ok, you can see your code in

/var/lib/hudson/jobs/YOUR_JOB_NAME/workspace

Add ci required rails plugins

Before you add these plugins, you need:

  • create a new branch
git checkout -b ci
  • Install ci_reporter plugin
./script/plugin install git://github.com/nicksieger/ci_reporter.git
  • Install rails_rcov_engines plugin
./script/plugin install git://github.com/dam5s/rails_rcov_engines.git

*

git add vendor/plugins/ci_reporter vendor/plugins/rails_rcov_engines

*

git commit -m "add ci related plugins"

Continue Configuration

Back to you job configuration, finish reset parts of configuration

  • Click the button Advanced.., above “Repository browser”
  • Enter ci
  • Build Triggers > Poll SCM */10 * * * * , Poll git commit every 10 mins
  • Build > Add build step > Execute shell, then enter
rake gems:install
export CI_REPORTS=results
export RAILS_ENV=test
export CI_REPORTS=results
export RAILS_ENV=test
# Prepare for rcov
[ -d "coverage" ] && rm -rf coverage
[ -d "results" ] && rm -rf results
mkdir coverage
mkdir results
# invoke rake
rake db:create db:migrate ci:setup:testunit test:test:rcov SHOW_ONLY=models,helpers,controllers RAILS_ENV=test RCOV_PARAMS="--aggregate coverage/aggregate.data"
  • Post-build Actions > Publish JUnit test result report enter results/*.xml
  • Post-build Actions > Publish Rcov report, enter coverage/test in Rcov report directory
  • Post-build Actions > E-mail Notification, config emails you want to send when test broke

Ok, you can click Build Now. After build you will see the test result code coverage.

> Test make perfect!



Ads Plugin created by Jake Ruston's Wordpress Plugins - Powered by and football database.