Nahshon paz Nahshon paz - 6 months ago 80
Groovy Question

Jenkins pipeline stages - passing whole file

Running a Jenkins pipeline (based on Groovy) with stages containing many nodes, I need to pass a list from some file on NodeA on stageA to nodeB on StageB.

In stageA NodeA I run

DEVenv = readFile 'somefile.txt'

In stageB I run

println DEVenv

So far so good, I get the output in the console.

Now how to pass the output of that
println DEVenv
to a file?

println DEVenv > otherfile.txt

doesn't do the trick :-(

I'm sure it's not such a big deal but I've been churning the internet for a couple of hours to no avail.


You can write content to a file using the writeFile step:

writeFile file: 'otherfile.txt', text: DEVenv)

Btw. In order to transfer workspace contents to another node, you are supposed to use the stash/unstash steps (not sure, if you use that already).