[英]Write to file with Jenkins and Groovy
When running my Jenkins build i need to update the contents of a file with a version number in this case. 运行我的Jenkins构建时,我需要在这种情况下使用版本号更新文件的内容。 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. 我遇到了一个名为
text-file-operations
的插件,但我没有写一个全新的文件,我认为更新会更好。
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. 在这个例子中,我有一个位于项目根目录中的podspec文件,它只需要使用我在此过程中创建的变量更新的版本号。
spec.version = '13.4.0'
I just need to convert that to 我只需将其转换为
spec.version = "${VERSION_NUMBER}"
Is there a way to do this ? 有没有办法做到这一点 ?
Is this what you want then? 这是你想要的吗?
Groovy + how to append text in file ( new line ) Groovy +如何在文件中附加文本(新行)
f = new File('<filename>')
f.append("spec.version = ${VERSION_NUMBER}\n")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.