Skip to content

Instantly share code, notes, and snippets.

@marcosborges
Created February 20, 2019 00:35
Show Gist options
  • Save marcosborges/3f8a8a7c82a97477e678d527f1c11e46 to your computer and use it in GitHub Desktop.
Save marcosborges/3f8a8a7c82a97477e678d527f1c11e46 to your computer and use it in GitHub Desktop.
def write(name, value){
def instance = Jenkins.getInstance()
def globalProps = hudson.model.Hudson.instance.globalNodeProperties
def props = globalProps.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)
for (prop in props) {
prop.envVars.put(name,value)
}
instance.save()
}
def all(){
def instance = Jenkins.getInstance()
def globalProps = hudson.model.Hudson.instance.globalNodeProperties
def props = globalProps.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)
return props.envVars
}
def find(name){
def instance = Jenkins.getInstance()
def globalProps = hudson.model.Hudson.instance.globalNodeProperties
def props = globalProps.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)
return props.envVars[name]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment