"Bundle command not found" in Jenkins
<p>I have a Groovy script that runs a job in a Jenkins pipeline but it fails when it tries to run <code>bundle</code>. I get the error </p>

<pre><code>bundle: command not found
</code></pre>

<p>I thought I was including the PATH variable in my build process but it seems that is not the case</p>

<pre><code>node {
  stage 'Bundle Build'
  withEnv(['PATH=/usr/bin:/bin:/usr/sbin:/:sbin/usr/local/bin:$PATH']) {
    sh '''bundle'''
  }
}
</code></pre>

<p>When I run <code>which bundle</code> I get <code>/Users/Jenkins/.rvm/gems/ruby/bin/bundle</code>, but my builds run under <code>/Users/Jenkins/.jenkins</code>.</p>

<p>How can I use bundle when building a job?</p>

<h2>Update</h2>

<p>If I run this however it works</p>

<pre><code>node {
  stage 'Bundle Build'
  withEnv(['PATH=/usr/bin:/bin:/usr/sbin:/:sbin/usr/local/bin:$PATH']) {
    sh '''#!/bin bash -l
          bundle'''
  }
}
</code></pre>

<p>But this doesn't seem right.</p>