title: Jenkins pipeline sh does not seem to respect pipe in shell command
body: <p>I am using a Jenkinsfile in a pipeline on version 2.32.2. </p>
  
  <p>For various reasons I want to extract the version string from the pom.  I was hoping I wouldn't have to add the maven help plugin and use evaluate.  </p>
  
  <p>I quickly came up with a little sed expression to get it out of the pom which uses pipes and works on the commandline in the jenkins workspace on the executor.</p>
  
  <p><code>
  $ sed -n '/&lt;version&gt;/,/&lt;version/p' pom.xml | head -1 | sed 's/[[:blank:]]*&lt;\/*version&gt;//g'
  1.0.0-SNAPSHOT
  </code></p>
  
  <p>It could probably be optimized, but I want to understand why the pipeline seems to be failing on piped sh commands.  I've played with various string formats and am currently using a dollar slashy string.</p>
  
  <p>The pipeline step looks like the following to allow for easy output of the command string:</p>
  
  <pre><code>script {
      def ver_script = $/sed -n '/&lt;version&gt;/,/&lt;version/p' pom.xml | head -1 | sed 's/[[:blank:]]*&lt;\/*version&gt;//g'/$
      echo "${ver_script}"
      POM_VERSION = sh(script: "${ver_script}", returnStdout: true)
      echo "${POM_VERSION}"
  }
  </code></pre>
  
  <p>When run in the jenkins pipeline I get the following console output where it seems to be separating the piped commands into separate commands:</p>
  
  <pre><code>[Pipeline] script
  [Pipeline] {
  [Pipeline] echo
  sed -n '/&lt;version&gt;/,/&lt;version/p' pom.xml | head -1 | sed 's/[[:blank:]]*&lt;\/*version&gt;//g'
  [Pipeline] sh
  [FRA-198-versioned-artifacts-44SD6DBQOGOI54UEF7NYE4ECARE7RMF7VQYXDPBVFOHS5CMSTFLA] Running shell script
  + sed -n /&lt;version&gt;/,/&lt;version/p pom.xml
  + head -1
  + sed s/[[:blank:]]*&lt;\/*version&gt;//g
  sed: couldn't write 89 items to stdout: Broken pipe
  [Pipeline] }
  [Pipeline] // script
  </code></pre>
  
  <p>Any guidance out there on how to properly use piped commands in a jenkinsfile ?</p>