How To Pass Data Between Pipeline Steps

Issue

Your pipeline script requires data during certain steps.

Environment

CloudBees Jenkins Enterprise

Resolution

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? Submit a request

0 Comments

Please sign in to leave a comment.