title: How to invoke bash functions defined in a resource file from a Jenkins pipeline Groovy script?
body: <p>We are using the <a href="https://github.com/jenkinsci/workflow-cps-global-lib-plugin" rel="noreferrer">Pipeline Shared Libraries</a> plugin to factorize the code common to our different Jenkins pipelines.</p>
  
  <p><a href="https://github.com/jenkinsci/workflow-cps-global-lib-plugin#directory-structure" rel="noreferrer">From its documentation</a>, it offers a <code>resources</code> top-level folder for non-Groovy files. As we rely on different bash functions, we would like to host them in a separate <code>.sh</code> file (thus they could also be used by other processes than Jenkins).
  The same documentation tells us about using <code>libraryResource</code> step to load those resource files. We can successfully call this method within our Groovy script, giving it our resource file name as argument (<code>function.sh</code>). But from here, we were not able to find a way to invoke the <code>foofoo</code> function defined in <code>function.sh</code> from the same Groovy script.</p>
  
  <pre><code>sh "foofoo"  #error: foofoo is not defined
  </code></pre>
  
  <p>We also tried to first source it like this:</p>
  
  <pre><code>sh "source function.sh &amp;&amp; foofoo"
  </code></pre>
  
  <p>But it fails at the <code>source</code> step, stating that <code>function.sh</code> is not found.</p>
  
  <p>What would be the correct procedure to invoke a bash function defined in <code>function.sh</code></p>