title: RVM failing to load for Jenkins build
body: <p>I'm trying to deploy an experimental Rails app within my enterprise. Everything here is setuo for Java development so I'm having to break new ground to gain acceptance for Rails in the company.</p>
  
  <p>I need to use Jenkins CI (v. 1.580) to deploy my Rails 4.1.4 app (ruby-2.1.2) on a CentOS (release 5.9) staging server here in the office, as a proof of concept before my app will be allowed near a production server.</p>
  
  <p>I've installed the following plugins in Jenkins and restarted: Hudson Ruby Plugin, rvm, Rake plugin, ruby-runtime, RubyMetrics plugin for Jenkins, GIT client plugin, GIT plugin, GitHub API Plugin, GitHub plugin</p>
  
  <p>The Jenkins build seems to be failing during an RVM initialisation script, output below.</p>
  
  <p>My Jenkins .bashrc file looks like this:</p>
  
  <pre><code>#/var/lib/jenkins/.bashrc
  [[ -s "$HOME/.rvm/scripts/rvm" ]] &amp;&amp; source "$HOME/.rvm/scripts/rvm"
  
  export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
  </code></pre>
  
  <p>And .rvmrc:</p>
  
  <pre><code>#/var/lib/jenkins/.rvmrc
  export rvm_trust_rvmrcs_flag=1 # always trust project .rvmrc
  export rvm_install_on_use_flag=1 # auto install rubies
  export rvm_gemset_create_on_use_flag=1 # auto install gemsets
  </code></pre>
  
  <p>I've tried nuking RVM and reinstalling using the multi-user instructions and have ensured that my jenkins user is a member of the rvm group.</p>
  
  <p>My build script looks like:</p>
  
  <pre><code>source ~/.bashrc         # Loads RVM
  cd .      # Loads the RVM environment set in the .rvmrc file
  # set env vars
  #export GEM_PATH=/usr/local/lib/ruby/gems/1.2/gems
  #export CI_REPORTS=results
  export RAILS_ENV=test
  #cp config/database.yml.example config/database.yml  
  # creates a database.yml
  bundle install           # Installs gems
  rake db:schema:load      # Loads all the database schema
  rake                     # Runs RSpec tests
  </code></pre>
  
  <p>Here's the complete Console Output from Jenkins</p>
  
  <pre><code>Started by user Pete
  Building in workspace /var/lib/jenkins/jobs/MerchantManager/workspace
   &gt; git rev-parse --is-inside-work-tree # timeout=10
  Fetching changes from the remote Git repository
   &gt; git config remote.origin.url https://github.com/***/epgDataPoc # timeout=10
  Fetching upstream changes from https://github.com/***/epgDataPoc
   &gt; git --version # timeout=10
  using .gitcredentials to set credentials
   &gt; git config --local credential.helper store --file=/tmp/git5734173224303904567.credentials # timeout=10
   &gt; git fetch --tags --progress https://github.com/***/epgDataPoc +refs/heads/*:refs/remotes/origin/*
   &gt; git config --local --remove-section credential # timeout=10
   &gt; git rev-parse refs/remotes/origin/master^{commit} # timeout=10
   &gt; git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
  Checking out Revision 8bced4d8fecd4135bcb4868aa4011e140adf46d3 (refs/remotes/origin/master)
   &gt; git config core.sparsecheckout # timeout=10
   &gt; git checkout -f 8bced4d8fecd4135bcb4868aa4011e140adf46d3
   &gt; git rev-list 8bced4d8fecd4135bcb4868aa4011e140adf46d3 # timeout=10
  [workspace] $ /bin/bash -xe /tmp/hudson1400066644804618273.sh
  + source /var/lib/jenkins/.bashrc
  ++ [[ -s /var/lib/jenkins/.rvm/scripts/rvm ]]
  ++ source /var/lib/jenkins/.rvm/scripts/rvm
  +++ builtin test -n '3.2.25(1)-release' -o -n ''
  +++ case "`uname`" in
  ++++ uname
  ++++ command ps -p 29628 -o ucomm=
  ++++ ps -p 29628 -o ucomm=
  +++ __shell_name=bash
  +++ case "$__shell_name" in
  +++ unset __shell_name
  +++ __rvm_has_opt posix
  +++ [[ -n '' ]]
  +++ [[ -n 3.2.25(1)-release ]]
  +++ [[ :braceexpand:errexit:hashall:interactive-comments:xtrace: =~ :posix: ]]
  +++ return 1
  +++ export HOME rvm_prefix rvm_user_install_flag rvm_path
  +++ HOME=/var/lib/jenkins
  +++ [[ -n '' ]]
  ++++ umask
  +++ export rvm_stored_umask=0022
  +++ rvm_stored_umask=0022
  +++ ((  0 == 0  ))
  +++ rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc")
  +++ [[ -n '' ]]
  +++ for rvmrc in '"${rvm_rvmrc_files[@]}"'
  +++ [[ -f /etc/rvmrc ]]
  +++ GREP_OPTIONS=
  +++ command grep '^\s*rvm .*$' /etc/rvmrc
  Build step 'Execute shell' marked build as failure
  Publishing rails stats report...
  hudson.model.StreamBuildListener@1bb557c8
  Finished: FAILURE
  </code></pre>