Jenkins Groovy Function To Be Used by Active Choice Parameter - To Have Auto Selected Based On Certain Logic
def get_list(x,delimiter,item_to_be_selected,bool_is_selected=false) {
list_selected = null
if(x!=null && x.length() > 0) {
list = x.split(delimiter)
list_selected = []
for(int i=0;i<list.size();i++){
if(bool_is_selected){
if(list[i].trim().equals(item_to_be_selected)){
list_selected[i] = list[i].trim() + ':selected'
}
else {
list_selected[i] = list[i].trim()
}
}
else {
list_selected[i] = list[i].trim()
}
}
}
return list_selected
}
Calling the function - return get_list(list_ota_servers,'-','t:98,d:http://updqa4.ubicquia.com',true)
No comments:
Post a Comment