2

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.

agabrys
  • 8,728
  • 3
  • 35
  • 73

1 Answers1

3

I found how to do it:

import hudson.slaves.EnvironmentVariablesNodeProperty
import jenkins.model.Jenkins

Jenkins.get().globalNodeProperties.get(EnvironmentVariablesNodeProperty).envVars['VARIABLE_NAME']
agabrys
  • 8,728
  • 3
  • 35
  • 73
  • like EnvironmentVariablesNodeProperty, is there EnvironmentVariablesBuildProperty? I want to use some of the env variable which are build specific – Toral Jul 25 '19 at 08:33
  • This is a configuration of the Extended Choice Parameter which represents an input for job build parameter. The build does not exist yet, so you cannot access any build environment variables. – agabrys Jul 26 '19 at 11:20