groovy 如何添加过滤器以从文件中读取属性?

flvlnr44  于 2022-11-01  发布在  其他
关注(0)|答案(1)|浏览(196)

在下面的示例中,如何忽略parameter_file中以_开头的键?
X1M2N1X含量:

project=prj/name
_project=bad/prj
_branch=badbranch
branch=mybranch

我需要过滤掉以_开头的键,并将其余的键收集到fileParams变量中,下面收集了parameter_file中所有可用的键,包括_project和_分支(我需要避免这两个)

props = readProperties file: "parameter_file"
fileParams = props.collect { string(name: it.key, value: it.value) }
build job: "jobName", parameters: fileParams
zaq34kh6

zaq34kh61#

props = readProperties file: "parameter_file"
fileParams = props.findAll{ !it.key.startsWith ('_') }.collect { string(name: it.key, value: it.value) }

相关问题