Preface: Sorry for my poor english.
So, today I started thinking on how can I compile my rails app to different Ruby versions. Luckily, I discovered, Jenkins can use RVM to run rake tasks.
I initialized rvm following this tutorial but I just skipped EC2 instance creation, because I currently has a CI server. I installed three ruby version, MRI 1.8.7, MRI 1.9.3, and JRuby latest stable.
First, I created a Rakefile.bootstrap file in my project root to make bundle install phase to rake-ized because I wouldn’t like run this via shell state, as because I need to select the correct rvm what is can be changed and I wouldn’t like administer it on thee or more places.
Then, I was naive. I thinked I use separated gemset to avoid infecting global ruby scope with my project’s gems.
This is quite easy, I sudo-ed to jenkins, and created gemset by
rvm gemset create rhcp. After viewing and saving Jenkins’ main configuration are, rake plugin recognized this gemset, and offered to use it.
I clicked on it, saved the project, clicked on build, and pray (in the future: c&p). No luck.
I spent a half of hour with investigation, and I found I need install rake to the target gemset too, not enough if it is installed with ruby or installed to the @global gemset. I installed rake, c&p. No luck.
After it, I ran into this problem. Because rake loaded twice, it lost in the stack, and just gave up.
So, I added rake proxy for my bootstrap Rake file. It means calls the rake command prefixed by ‘bundle exec’ since Jenkins cannot do this. Bundler cleans out unneccessary gems (eg.g what coming from @global, or from ruby itself) and executes rake command.
This is the final Rakefile.bootstrap if you want to use it: