Jenkins pipeline stages - passing whole file

邮差的信 提交于 2019-12-08 02:14:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!