Not sure if anyone cares, but this is what I got working based on an example I found on the groovy plugin page: (there is likely way better ways to manage this)
import hudson.util.* import hudson.model.* // get current thread / Executor def thr = Thread.currentThread() // get current build def build = thr?.executable // ... or if you want the parameter by name ... def hardcoded_param = "NEW_PROP" def resolver = build.buildVariableResolver def hardcoded_param_value = resolver.resolve(hardcoded_param) for (nodeproperty in hudson.model.Hudson.instance.globalNodeProperties) { println(nodeproperty.getEnvVars()); if(nodeproperty.getEnvVars().get("FOO") != null) { nodeproperty.getEnvVars().put("FOO", hardcoded_param_value); hudson.model.Hudson.instance.save(); println(nodeproperty.getEnvVars()); } } On Tuesday, April 24, 2012 4:06:46 PM UTC-4, Maven User wrote: > > Hi all - > > I have a job that needs to execute a groovy pre- step that sets a global > environment variable. > > Is there anyway to do this? > > I have tried the following: > > for (nodeproperty in hudson.model.Hudson.instance.globalNodeProperties) > { > println(nodeproperty.getEnvVars()); > nodeproperty.getEnvVars().put("FOO", nextdevversion); > hudson.model.Hudson.instance.save(); > println(nodeproperty.getEnvVars()); > } > > and then set: > > nextdevversion=NEXT_DEV_VERSION > > In the variable bindings - but that just set the global environment > variable to "NEXT_DEV_VERSION". > > I've tried: > > ${NEXT_DEV_VERSION} > $NEXT_DEV_VERSION > ${env.NEXT_DEV_VERSION} > > None of these are the actual parameter. > > Is this just not possible? >