How to set variables in a multi-line shell script within Jenkins Groovy?
<p>Suppose I have a Groovy script in Jenkins that contains a multi-line shell script. How can I set and use a variable within that script? The normal way produces an error:</p>

<pre><code>sh """
    foo='bar'
    echo $foo
"""
</code></pre>

<blockquote>
  <p>Caught: groovy.lang.MissingPropertyException: No such property: foo for class: groovy.lang.Binding</p>
</blockquote>