-
Task
-
Resolution: Fixed
-
Minor
I want a the choice option values be populated at runtime by a function.
The following code should to generate a list of options, but for some reason its not working ...
def getEnv() { return["Dev","Prod"] } def getServerByEnvParam(env_param) { if (env_param.equals("Dev")){ return["dev01","dev02"] } else if(env_param.equals("Prod")){ return["prd001","prd02"] } else { return["unknown"] } } properties([ parameters([ [$class: 'ChoiceParameter', choiceType: 'PT_SINGLE_SELECT', description: 'Select Environment', name: 'myEnv', script: [ $class: 'GroovyScript', fallbackScript: [ classpath: [], sandbox: false, script: 'return[\'myEnv Error\']' ], script: [ classpath: [], sandbox: false, script: 'return getEnv()' ] ] ], [$class: 'CascadeChoiceParameter', choiceType: 'PT_SINGLE_SELECT', description: 'Select Server', filterable: false, name: 'myServer', referencedParameters: 'myEnv', script: [ $class: 'GroovyScript', fallbackScript: [ classpath: [], sandbox: false, script: 'return[\'myServer Error\']' ], script: [ classpath: [], sandbox: false, script: 'return getServerByEnvParam(myEnv)' ] ] ] ]) ]) pipeline { agent any stages { stage('Init') { steps { script{ println getServerByEnvParam(myEnv) } } } } }
how can I to define and use these functions inside jenkins file?
is a pipeline supports dynamic parameters based on function in shared libraries?
- duplicates
-
JENKINS-63284 Add support to Pipeline API
-
- Open
-
Hi stamnik
The code was originally written for the FreeStyle jobs. Its relies heavily on the HTML/DOM of the parameters.
We have been getting lots of requests to support pipelines, however, the main block for me is finding time to focus on this task.
I've heard from users who were able to use the plug-in, but I am not sure how that works, and have never tried it.
Will close as duplicate of the issue for Pipelines, feel free to subscribe there for updates. Normally I have spare time around holidays in New Zealand (October there's one, then x-mas), and pretty much always use it to work on OSS projects, including this plug-in.
But should there's a PR before that, I will review and release asap.
Cheers
Bruno