栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Jenkins管道中使用Groovy创建具有某些内容的文件

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Jenkins管道中使用Groovy创建具有某些内容的文件

Jenkins
Pipeline提供

writeFile
了可用于在作业的工作空间内写入文件的步骤。

看下面的例子:

node {    writeFile file: 'groovy1.txt', text: 'Working with files the Groovy way is easy.'    sh 'ls -l groovy1.txt'    sh 'cat groovy1.txt'}

运行此管道脚本将生成以下输出:

[Pipeline] nodeRunning on Jenkins in /var/jenkins_home/workspace/test-pipeline[Pipeline] {[Pipeline] writeFile[Pipeline] sh[test-pipeline] Running shell script+ ls -l groovy1.txt-rw-r--r-- 1 jenkins jenkins 42 Jul  8 16:38 groovy1.txt[Pipeline] sh[test-pipeline] Running shell script+ cat groovy1.txtWorking with files the Groovy way is easy.[Pipeline] }[Pipeline] // node[Pipeline] End of PipelineFinished: SUCCESS

使用Java
File

正如乔恩小号在评论中提到,爪哇

newFile("${env.WORKSPACE}/groovy1.txt")
将工作 如果你的节点步骤主节点上执行-
如果它得到从属节点上执行,然后你的管道代码将失败。您可以检查以下堆栈溢出线程以获取更多信息



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/507066.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号