小编典典

如何从Jenkins 2.0管道脚本读取属性文件

jenkins

我正在尝试编写管道脚本以与Jenkins
2.0一起使用来复制我们现有的构建。这个原始版本使用envInject插件读取Java属性文件,但是我看不到如何从管道Groovy脚本中执行此操作。我已经用Google搜索并找到了以下内容,但是它不起作用(FileNotFoundException):

Properties props = new Properties()
File propsFile = new File('./Builder/project.properties')
props.load(propsFile.newDataInputStream())

谢谢!


阅读 298

收藏
2020-07-25

共1个答案

小编典典

我只是昨天和今天为此而战。我希望此功能更容易找到。

抓住“ Pipeline Utility Steps ”插件。

使用readProperties步骤。

 def props = readProperties  file: 'dir/my.properties'

一句话警告-我期望属性文件中的布尔值被视为字符串。

2020-07-25