0

Currently I am using the following piece of code to generate dynamic parameters by reading from a properties file using the 'groovy script' option in 'active choice parameter'

jenkinsURL=jenkins.model.Jenkins.instance.getRootUrl()

def propFile="build_choices.properties" //name of properties file
def propKey="test" // name of properties key
def relPropFileUrl="userContent/" // userContent/properties/
def propAddress="${jenkinsURL}${relPropFileUrl}$propFile"
def props= new Properties()
props.load(new URL(propAddress).openStream())
def choices=[]

props.get(propKey.toString()).split(",").each{
  choices.add(it)
    }

return choices

This is currently working in version 'ver. 2.60.3' but does not work in higher versions eg: 'ver. 2.102'. Is there a solution that works across all the versions?

1 Answers1

1

I just found out, there is actually a much easier way to read parameters from a property file using Extended Choice Parameter Plugin.

You have to provide 'Parameter Type' and 'Delimiter' in 'Basic Parameter Types' and select the 'Choose Source for Value' option to provide the 'Property file' path and 'Property key' values.