-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAC_GetCollectionPropertyKey.groovy
More file actions
33 lines (26 loc) · 1023 Bytes
/
AC_GetCollectionPropertyKey.groovy
File metadata and controls
33 lines (26 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*** BEGIN META {
"name" : "AC_GetCollectionPropertyKey.groovy",
"comment" : "Retrieves a property key residing in a static properties file, key value can be list or map",
"parameters" : [ 'vPropFile','vPropKey','vRelPropFileUrl'],
"core": "1.593",
"authors" : [
{ name : "Ioannis K. Moutsatsos" }
]
} END META**/
jenkinsURL=jenkins.model.Jenkins.instance.getRootUrl()
def propFile=vPropFile //'dataType.properties'
def propKey=vPropKey// "file.content"
def relPropFileUrl=vRelPropFileUrl // userContent/properties/
def propAddress="${jenkinsURL}${relPropFileUrl}$propFile"
def props= new Properties()
props.load(new URL(propAddress).openStream())
def choices=[:]
//logic handles a map to be evaluated or a simple string
if (props.get(propKey.toString()).startsWith('[') && props.get(propKey.toString()).endsWith(']')) {
choices=evaluate(props.get(propKey.toString()))
}else{
props.get(propKey.toString()).split(",").each{
choices.put(it,it)
}
} //assume a list
return choices