How to pass data between pipeline steps?


Your pipeline script requires data during certain steps.


CloudBees Jenkins Enterprise


The Pipeline script needs to use the results of one of the calls to determine the input data to the next call. This is possible pending JENKINS-26133 by writing the data to a file which is consumed by the next step.

Please note that the steps can be run on different nodes by doing the following:

def content
node {
  sh 'curl -s http://server/api1/resource > .resource'
  content = readFile '.resource'
node {
  sh "curl -s http://server/api2/${content} > .resource"
  // …

Have more questions?


  • 0
    Darren Graham

    typo: script in 2nd node {} should be sh 'curl....'

  • 0
    Denys Digtiar

    Thank you for pointing it out. I have updated the article. Note, though, that in the second node block double quotes must be used since string interpolation is involved.

    Edited by Denys Digtiar
Please sign in to leave a comment.