title: extract version from package.json with bash inside jenkins pipeline
body: <p>Script in package.json:</p>
  
  <pre><code>"scripts": {
      "version": "echo $npm_package_version"
    },
  </code></pre>
  
  <p>One of the stage in Jenkins pipeline:</p>
  
  <pre><code>stage('Build'){
      sh 'npm install'
      def packageVersion = sh 'npm run version'
      echo $packageVersion
      sh 'VERSION=${packageVersion} npm run build'
  }
  </code></pre>
  
  <p>I got version from npm script output, but following line</p>
  
  <pre><code>echo $packageVersion
  </code></pre>
  
  <p>return null</p>
  
  <p>Is packageVersion value not correctly assigned?</p>
  
  <p>Edited:
  when using Pipeline Utility Steps with following code</p>
  
  <pre><code>stage('Build'){
      def packageJSON = readJSON file: 'package.json'
      def packageJSONVersion = packageJSON.version
      echo packageJSONVersion
      sh 'VERSION=${packageJSONVersion}_${BUILD_NUMBER}_${BRANCH_NAME} npm run build'
          }
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>[Pipeline] echo
  1.1.0
  [Pipeline] sh
  [...] Running shell script + VERSION=_16_SOME_BRANCH npm run build
  </code></pre>
  
  <p>So I am able to extract version, but still cannot pass it when running script</p>