如何从Jenkins 2.0管道脚本读取属性文件 [英] How to read properties file from Jenkins 2.0 pipeline script
问题描述
我正在尝试编写一个管道脚本来与Jenkins 2.0一起使用来复制我们现有的构建。这个原始版本使用envInject插件来读取一个Java属性文件,但我看不到如何从流水线Groovy脚本执行此操作。我有谷歌搜索,发现以下,但它不起作用(FileNotFoundException):
Properties props = new Properties()
文件propsFile = new File('./ Builder / project.properties')
props.load(propsFile.newDataInputStream())
谢谢!
昨天和今天,我希望这个更容易找到。
抓住管道实用程序步骤'插件。 使用readProperties步骤。
def props = readProperties file:'dir / my.properties'
一个警告字 - 我预期在属性文件中是布尔值时被视为字符串。
I am attempting to write a pipeline script to use with Jenkins 2.0 to replicate our existing build. This original build used the envInject plugin to read a Java properties file, but I can't see how to do this from the pipeline Groovy script. I have Googled and found the following, but it doesn't work (FileNotFoundException):
Properties props = new Properties()
File propsFile = new File('./Builder/project.properties')
props.load(propsFile.newDataInputStream())
Thanks!
I just fought with this yesterday and today. I wish the availability of this was easier to find.
Grab the 'Pipeline Utility Steps' plugin.
Use the readProperties step.
def props = readProperties file: 'dir/my.properties'
One word of warning - what I expected to be booleans in the properties files were treated as strings.
这篇关于如何从Jenkins 2.0管道脚本读取属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!