Using RVM?

My builder server needs to be able to test against Ruby 1.8 for some projects, and 1.9 for others.

I've been using RVM with hudson to make this work the way I need.

I'm after some advice on how to do this with TeamCity

5 comments

Hello Alan,

My builder server needs to be able to test against Ruby 1.8 for some projects, and 1.9 for others.

I've been using RVM with hudson to make this work the way I need.

I'm after some advice on how to do this with TeamCity

TeamCity doesn't provide special support for RVM (see http://youtrack.jetbrains.net/issue/TW-11444  issue). So you need setup GEM_PATH, GEM_HOME and PATH environment variables manually.

There are several ways how to configure TC:
1. The easiest:
* In "Rake" runner settings specify "Ruby Interpreter path".
  E.g.:
    /Users/buildserver/.rvm/rubies/ruby-1.9.1-p378/bin/ruby
* In "Properties and Environment Variables" section please configure GEM_PATH and GEM_HOME env variables.
  E.g.:
   GEM_PATH = /Users/buildserver/.rvm/gems/ruby-1.9.1-p378:/Users/buildserver/.rvm/gems/ruby-1.9.1-p378%global
   GEM_HOME = /Users/buildserver/.rvm/gems/ruby-1.9.1-p378
   PATH = /Users/buildserver/.rvm/rubies/ruby-1.9.1-p378/bin:/Users/buildserver/.rvm/gems/ruby-1.9.1-p378/bin:/Users/buildserver/.rvm/gems/ruby-1.9.1-p378%global/bin:/Users/buildserver/.rvm/bin:%env.PATH%

   or

   GEM_PATH = /Users/buildserver/.rvm/gems/ruby-1.9.1-p378%your_gemset_name:/Users/buildserver/.rvm/gems/ruby-1.9.1-p378%global
   GEM_HOME = /Users/buildserver/.rvm/gems/ruby-1.9.1-p378%your_gemset_name
   PATH = /Users/buildserver/.rvm/rubies/ruby-1.9.1-p378/bin:/Users/buildserver/.rvm/gems/ruby-1.9.1-p378%your_gemset_name/bin:/Users/buildserver/.rvm/gems/ruby-1.9.1-p378%global/bin:/Users/buildserver/.rvm/bin:%env.PATH%

2. More universal way. E.g. if .rvm paths differs on agents. You need configure several ruby interpreters on each agent and then choose corresponding settings in build configuration.
On each rvm agent:
system.teamcity.ruby.interpreter.rvm.ruby19 = /Users/buildserver/.rvm/rubies/ruby-1.9.1-p378/bin/ruby
system.teamcity.ruby.interpreter.rvm.ruby19.gempath = ..
system.teamcity.ruby.interpreter.rvm.ruby19.gemhome = ..

system.teamcity.ruby.interpreter.rvm.ruby19.path = .. :%env.PATH%
system.teamcity.ruby.interpreter.rvm.ruby18 = ..

system.teamcity.ruby.interpreter.rvm.ruby18.gempath = ..
system.teamcity.ruby.interpreter.rvm.ruby18.gemhome = ..


then in project build configuration settings:

"Ruby Interpreter path" : %system.teamcity.ruby.interpreter.rvm.ruby19%

GEM_PATH = %system.teamcity.ruby.interpreter.rvm.ruby19.gempath%
GEM_HOME = %system.teamcity.ruby.interpreter.rvm.ruby19.gemhome%
PATH = %system.teamcity.ruby.interpreter.rvm.ruby19.path%


0

Hey guys,

Be sure to also set BUNDLE_PATH if you're using Bundler.

Rob

0

TC 5.1.3 includes RVM support with sets necessary env variables automatically

0

Hi Roman,

Are you saying that the Rake runner would obey a .rvmrc, load the right Ruby and set all the environment variables appropriately?  That would be amazing!

Anywhere I can read more?

Rob

0

Are you saying that the Rake runner would obey a .rvmrc, load the right Ruby and set all the environment variables appropriately?  That would be amazing!

I mean that you can specify rvm gemset name in Rake runner settings and agent will set all necessary env variables before executing rake task.

Anywhere I can read more?


Feature isn't polished yet and planned to TC 6.0 release, but some initial version has been already included in 5.1.3. TC documentation for the feature will be available later. Today I saw some 3rd party faq related to rvm & TC 5.1.3 - http://blog.carbonfive.com/2010/08/ruby-on-rails/using-rvm-on-teamcity-build-agents/comment-page-1#comment-3420.

0

Please sign in to leave a comment.