用Jenkins和Groovy写入文件 [英] Write to file with Jenkins and Groovy

查看:510
本文介绍了用Jenkins和Groovy写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行我的Jenkins版本时,在这种情况下,我需要使用版本号更新文件的内容.我遇到了一个名为text-file-operations的插件,但是与其编写一个新文件,不如我认为更新会更好.

When running my Jenkins build i need to update the contents of a file with a version number in this case. I have come across a plugin called text-file-operations but rather than write a whole new file I thought it would be better to update.

在此示例中,我在项目的根目录中有一个podspec文件,该文件只需要使用在过程中较早创建的变量更新版本号即可.

In this example I have a podspec file located in the root of the project which just needs a version number updated with a variable I have created earlier in the process.

spec.version               = '13.4.0'

我只需要将其转换为

spec.version               = "${VERSION_NUMBER}"

有没有办法做到这一点?

Is there a way to do this ?

推荐答案

这就是您想要的吗?

Groovy +如何在文件中附加文本(换行)

f = new File('<filename>')
f.append("spec.version               = ${VERSION_NUMBER}\n")

这篇关于用Jenkins和Groovy写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆