How to set the output of sh to a Groovy variable?
<p>Is it possible to have the output of the <code>sh</code> command be set to a Groovy variable? It seems to be setting it to the status of the command instead.</p>

<p>Example input:</p>

<pre><code>node {
   stage "Current Date"
   def curDate = sh "date"
   echo "The current date is ${curDate}"
}
</code></pre>

<p>Results in the following output:</p>

<pre><code>Entering stage Current Date
Proceeding
[Pipeline] sh
[workspace] Running shell script
+ date
Tue May 10 01:15:05 UTC 2016
[Pipeline] echo
The current date is 0
</code></pre>

<p>It is showing <code>The current date is 0</code>, I want it to show <code>The current date is Tue May 10 01:15:05 UTC 2016</code> which you can see has been output by the sh command. Am I going about this all wrong?</p>