RVM Setup in TC 7.0.1

I've been fighting to get Ruby testing with RVM working in TeamCity 7.0.1.  Here's my setup.

  • Linux EC2 instance
  • TeamCity web interface served via Tomcat running under the user, "tomcat".
  • Build agent installed (via agent push) on the same machine under the user, "teamcity".
  • The user "teamcity" has RVM installed at the user level, not system level.  So rvm resides in ~teamcity/.rvm/bin.
  • This RVM has the following ruby and gemset configured: ruby-1.9.3-p125@my_gemset.


My problem is that, depending on my build configuration, I receive the error that "RVM" cannot be found or that the gemset/interpretter do not exist.  I've tried about ever permutation of build parameters, paths, build features, build steps, etc all to no avail.  I then stripped my testing down to two basic cases.  Both of these tests included the same build steps.

1. run "whoami"
2. run "ruby -v"
3. run "rvm list"
rvm_not_found_build_steps.jpg
In the first test, I set the build feature to "RVM interpreter" and entered my ruby version and "my_gemset".
interpreter_build_feature.jpg
I also set the appropriate build parameters.
env.TEAMCITY_GIT_OATH: /usr/bin
env.rvm_path: /home/teamcity/.rvm/bin (I also tried ~/.rvm/bin and other permutations with no success)
rvm_not_found_build_params.jpg
With these settings, the build fails on step 1, complaining that the interpretter or gemset cannot be found.
"[Step 1/3] Gemset 'my_gemset' isn't defined for Ruby interpreter 'ruby-1.9.3-p125' or the interpreter doesn't exist or isn't a file or isn't a valid RVM interpreter name."
interpreter_build_log.jpg



I then tried to use the system Ruby and Global gemset, just to make sure the RVM functionality was working.
rvm_not_found_build_feature.jpg
This time it failed on step 3, "rvm list" complaining that the command "rvm" could not be found.
rvm_not_found_build_log.jpg

[12:46:45]Step 1/3: Whoami (Command Line)
[12:46:45][Step 1/3] Starting: /bin/sh /home/teamcity/BuildAgent/temp/agentTmp/build7606554237867993998.sh
[12:46:45][Step 1/3] in directory: /home/teamcity/BuildAgent/work/6c8008638eb39563
[12:46:46][Step 1/3] teamcity
[12:46:46][Step 1/3] Process exited with code 0
[12:46:46]Step 2/3: Ruby Version (Command Line)
[12:46:46][Step 2/3] Starting: /bin/sh /home/teamcity/BuildAgent/temp/agentTmp/build8522733062657864515.sh
[12:46:46][Step 2/3] in directory: /home/teamcity/BuildAgent/work/6c8008638eb39563
[12:46:47][Step 2/3] ruby 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux]
[12:46:47][Step 2/3] Process exited with code 0
[12:46:47]Step 3/3: RVM List (Command Line)
[12:46:47][Step 3/3] Starting: /bin/sh /home/teamcity/BuildAgent/temp/agentTmp/build7737303470263275708.sh
[12:46:47][Step 3/3] in directory: /home/teamcity/BuildAgent/work/6c8008638eb39563
[12:46:48][Step 3/3] /home/teamcity/BuildAgent/temp/agentTmp/build7737303470263275708.sh: line 2: rvm: command not found
[12:46:48][Step 3/3] Process exited with code 127
[12:46:48][Step 3/3] Step RVM List (Command Line) failed

As I said, I feel like I've tried every possible permutation of build feature, build steps, build params, etc all with the same 2 outcomes.  And anyone PLEASE offer some guidance on configuring 7.0.1 to work correctly with RVM?  Thanks.

4 comments
Comment actions Permalink

experiencing the exact same problem.

0
Comment actions Permalink

Hi John,

Sorry for later reply.

About first problem:

Build fails because "Failure build if interpreter not found" feature is on. Before first step Ruby Environment Configurator tries to configure Env and fail build because 'ruby-1.9.3-p125@my_gemset' not found.
If it exist in RVM then it's our bug. But in 7.1 REC code was rewrited to use rvm-shell and now this problem is obsolete.


About second problem:


RVM may be not found because bash running in non-login mode. ( "~/.bashrc" and "~/.bash_profile" does not applied ).
You can add ". ~/.bashrc" to your build script or use Ruby Environment Configurator build feature (recommended).

0
Comment actions Permalink

Thanks for the feedback.  I did eventually get this working on 7.0.1.  I believe it was a bug with that version.  The solution that finally worked was to delete the env.RVM_PATH parameter.  Having that param, no matter what I put in there, seemed break RVM.

We're now running 7.1 with 15+ projects and haven't had any more problems.  I'm including screenshots of typical build steps and build params we use, as someone might find it useful.

This is for one of our typical RoR project using RVM.  The agent is running as a user called "teamcity".  Each project has it's own gemset.  We store the various settings files (database.yml, ses.yml, etc) for each project on disk in ~teamcity/shared and symlink them into the project as a build step.  This works for us as we only have one agent, but going forward we should check all these settings files into a repo and check them out as part of the build process.



Attachment(s):
build_steps.jpg
build_params.jpg
0
Comment actions Permalink

You configuration looks great!

Also you can move rvm interpreter installation into another build configuration (because it's time-dependent) and run it when new installation required. And you can set build parameter "rvm.rubies.list" requirement to satisfy required interpreter name.

In 7.1  RubyEnvConfigurator can create gemsets automatically, but interpreter required at build start moment.

Develop with pleasure!

0

Please sign in to leave a comment.