问题
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.
回答1:
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).
来源:https://stackoverflow.com/questions/40769318/jenkins-pipeline-stages-passing-whole-file