我目前在 Jenkins 中使用主动选择参数和反应参数,并且我能够使用此脚本从属性文件填充反应参数中的值。
主动选择反应参数 Groovy 脚本:
Properties properties = new Properties()
File propertiesFile = new File ('Properties file Path')
propertiesFile.withInputStream {
properties.load(it)
}
if (ACP.equals('Test1')){
def array = properties.test1.split(',')
return [array[0],array[1],array[3]]
}
每次向属性文件添加新值时,我还需要向脚本添加额外的数组(数组[4])。 我有什么方法可以根据属性文件中的值的数量自动填充数组?
我试过了,但没用。
def array = properties.getProperties(test1).split(',')
return array
我能够找到使用此脚本的方法:
def options = []
array.each { key ->
options.add(key)
}
return options