I am using dynamic param “jdk_version” to load JDK version based on the reference parameter Application version “app_version”. I am able to load JDK version using switch block in script. To optimize the code, tried to pass app_version to a common method, but it is not sending the updated app_version value. Is there any other way to pass app_version value to common method or remove these many switch conditions? Thank you.
What do you mean with common method? It must be a method that is within the script string of the parameter. You can’t call methods that are defined in the Jenkinsfile directly.
I am able to call a common method from the script, but, not able to pass ref param ‘app_version’ to common method. app_version value always remains the same. I am expecting it’s value to change on the app_version value change
You should be aware that when you enter the parameters of a job the pipeline is not yet running. So all the active choice parameter has is what is in it’s script argument. The method getJdkVersion is not known at that point in time.
Now when the pipeline starts running it will update the parameter definition. As you used double quotes it will evaluate the call to getJdkVersion and write the return value of that call into the script.
So the script is not dynamic. You should see this when you look at the config.xml of the job. It guess in the script block of the parameter you will only see the return value of the method call.