jenkinsjenkins-pluginsextended-choice-parameter

How to get Jenkins environment variables in Extended Choice Parameter plugin


I have to define a single select combo box where a list of available values is defined in a Jenkins environment variable (Manage Jenkins → Configure System → Global properties → Environment variables). How could I achieve that?

I tried to use build and env objects, but they are undefined.


Solution

  • I found how to do it:

    import hudson.slaves.EnvironmentVariablesNodeProperty
    import jenkins.model.Jenkins
    
    Jenkins.get().globalNodeProperties.get(EnvironmentVariablesNodeProperty).envVars['VARIABLE_NAME']