title: How do I pass variables between stages in a declarative Jenkins pipeline?
body: <p>How do I pass variables between stages in a declarative pipeline?</p>
  
  <p>In a scripted pipeline, I gather the procedure is to write to a temporary file, then read the file into a variable.</p>
  
  <p>How do I do this in a declarative pipeline?</p>
  
  <p>E.g. I want to trigger a build of a different job, based on a variable created by a shell action.</p>
  
  <pre><code>stage("stage 1") {
      steps {
          sh "do_something &gt; var.txt"
          // I want to get var.txt into VAR
      }
  }
  stage("stage 2") {
      steps {
          build job: "job2", parameters[string(name: "var", value: "${VAR})]
      }
  }
  </code></pre>