title: jenkinsfile not passing env to sh
body: <p>I am trying to set environment variable in Jenkinsfile following way, </p>
  
  <pre><code>pipeline {
      agent { label 'slave1' }
  
      stages {
          stage ('Build') {
              steps {
                  script {
                      BUILD_VERSION = sh (
                          script: 'python get_firmware_version.py',
                          returnStdout: true
                      ).trim()
                  }
                  echo "${BUILD_VERSION}"
                  withCredentials([file(credentialsId: 'image-sign', variable: 'IMAGE_SIGN')]) {
                      dir('firmware/') {
                          echo "${BUILD_VERSION}"
                          sh '''
                             echo "Building"
                             echo "${BUILD_VERSION}"
                             echo "${env.BUILD_VERSION}"
                          '''
                      }
                  }
              }
          }
      }
      post {
          failure {
              script {
                  echo "Pipeline Failed"
              }
          }
      }
  }
  </code></pre>
  
  <p>But its failing with following error <code>Bad substitution</code></p>
  
  <pre><code>[Pipeline] echo
  0_2_0
  [Pipeline] sh
  + echo Building
  Building
  /home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: 3: /home/jenkins/jenkins_slave/workspace/Firmware/Branch/firmware@tmp/durable-54e04481/script.sh: Bad substitution
  </code></pre>
  
  <p>Why I can't set ENV Var and use it in sh step ?</p>