Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

LABS
Rails 3 with RVM and Cruise Control

Here are a few notes on how to get individual CruiseControl.rb project Builders running with RVM.

[Note: I’m making an assumption here that you know and understand Bundler and RVM.]

[Also: Cruise may or may not be running on RVM]

Create and check in a .rvmrc file in your rails root directory. Here’s an example.


rvm ruby-1.8.7-p174@rails-example

Then, add a project build command to your cruise_config.rb file.


Project.configure do |project|
  project.build_command = './cruise_build.sh'
end

Finally, create a cruise_build.sh file. The bash script setups rvm and just calls your cruise control build task.

[Note: Your cruise rake task should probably call Bundler’s “bundle install”.]


#!/bin/sh

source $HOME/.rvm/scripts/rvm && source .rvmrc

rake cc:build

…and your cruise project builder is now using RVM!

Comments
  1. Chad Woolley says:

    The best shebang is:

    #!/usr/bin/env bash

    Also, using an .rvmrc IS centralizing your settings – for developers as well as CI.

    — Chad

  2. Alex Chaffee says:

    An `.rvmrc` file changes the current ruby every time you `cd` into its directory. But the preferred version for an individual developer may or may not be the preferred version for a collective CI instance. So I prefer not to check in `.rvmrc` files because that would clobber individual developers’ own ruby settings. (How annoying would it be if you were working on 1.9 compatibility and kept getting your ruby switched out to 1.8? Or if you accidentally checked in your 1.9 .rvmrc and annoyed everyone else?)

    Also, I’d like to get CI to run the same tests on many rubies, one after another. I’m already doing that in [Wrong](http://github.com/sconover/wrong) and I may do it in Erector (extending the above script) soon. But if I were using an `.rvmrc` then it would naturally conflict with all but one of the iterations…

    So if you agree with me then `.rvmrc` should always be in `.gitignore` and never checked in.

  3. Curtis Schofield says:

    @Chad Wooley

    On ubuntu it is :

    #!/bin/env bash

    Do you know any way to detect that?

    I agree that .rvmrc is a centralized setting – avoid checking it in by accident if you change it.

  4. Curtis Schofield says:

    btw Mike – nice post!

  5. Thanks for the post Mike. I had major issues getting RVM to play nice with CC, but this post did help.

    As an aside, I found Hudson more straightforward, and will be writing up instructions on how to set up Hudson + RVM + gemsets on Ubuntu.

  6. Mike Barinek says:

    Hi Sandeep,

    We also use hudson. You might also like cimonitor – https://github.com/pivotal/cimonitor

    it’s been a while, we should catch up soon…

  7. Reccur Nishan says:

    Thanks man! Awesome post. :)

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *