title: Getting RVM to work with Jenkins Pipeline
body: <p>So I'm trying to setup a Jenkins declarative Pipeline to run an Xcode build job. I want to use xcpretty Ruby gem but will also need several other Ruby gems later for other jobs.</p>
  
  <pre><code>stage('Pre-Build')
  {
      steps
      {
          echo "Executing Pre-Build steps ..."
          sh(returnStdout: true, script: "#!/bin/bash -xle &amp;&amp; source ~/.rvm/scripts/rvm &amp;&amp; rvm use 2.3.1 &amp;&amp; cd ${WORKSPACE}/${env.PROJECT_PATH} &amp;&amp; gem install xcpretty &amp;&amp; set -o pipefail &amp;&amp; xcpretty")
      }
  }
  </code></pre>
  
  <p>First off all, I get no echo for the sh in Pre-Build stage whatsoever. Neither <code>returnStdout: true</code> nor the hashbang seem to have any effect on getting any log output from the shell invocation.</p>
  
  <p>That leaves me blind on what's going on here. When running the job, the Pre-Build stage passes and then it fails at my actual build stage when I want to use xcpretty.</p>
  
  <p>Here's the log output from the Pre-Build stage:</p>
  
  <pre><code>Executing Pre-Build steps ...
  [Pipeline] script
  [Pipeline] {
  [Pipeline] sh
  [job] Running shell script
  [Pipeline] }
  [Pipeline] // script
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (Build)
  [Pipeline] echo
  </code></pre>
  
  <p>If I run it in the bash manually, no problem! On Jenkins it seems that something isn't working with RVM but I'm tapping in the dark while trying to fix this for days and it drives me insane.</p>
  
  <p>Any help is appreciated!</p>