Can I use script from jenkins shared library to load options from .json file? I have script in /vars dir which is used to return entries from json file. This is my parameters section:
parameters([
[$class: 'CascadeChoiceParameter',
choiceType: 'PT_MULTI_SELECT',
description: 'Select machines',
filterLength: 1,
filterable: true,
name: 'machineNames',
referencedParameters: '',
script: [$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: false,
script: 'return ["Please select a deliverable first"]'
],
script: [
classpath: [],
sandbox: false,
script: 'return loadMachineList()'
]
]
],
...
loadMachineList() function is returning list of machines separated with coma. Function itself it is working, I verified it in build.
When I try to run job ("build with parameters") there are any options to choose from.
I verified the script itself - it works. I tried to call script as loadMachineList(), vars/loadMachinesList() but without result.
I'm afraid no, AFAIK the script has to be inline and you can't load the script from external sources. One workaround is to add your script into a custom Jar and point to the custom Jar in classpath[]
section. Apart from that, whatever you put in the Script section within the Properties block must be self-contained.