Reputation: 163
I have a job with a text parameter called LOCAL_IP
then I'm using Extensible choice parameter plugin to insert a Groovy Script, I'm trying to get the LOCAL_IP
parameter with no success, anyone knows what I'm doing wrong? here is my code:
import hudson.model.*
def build = this.getProperty(‘binding’).getVariable(‘build’)
def listener = this.getProperty(‘binding’).getVariable(‘listener’)
def env = build.getEnvironment(listener)
return env.LOCAL_IP
Getting this error atm:
startup failed:
Script1.groovy: 3: Invalid variable name. Must start with a letter but was: ‘binding’
. At [3:30] @ line 3, column 30.
def build = this.getProperty(‘binding’).getVariable(‘build’)
^
1 error
I have read the documentation from https://wiki.jenkins.io/display/JENKINS/Groovy+plugin at the end of page and tryed what they say with no results:
import hudson.model.*
import hudson.AbortException
import hudson.console.HyperlinkNote
import java.util.concurrent.CancellationException
// Retrieve parameters of the current build
def foo = build.buildVariableResolver.resolve("FOO")
println "FOO=$foo"
and also
System.getProperty('FOO')
Tested inside the console in plugin but still not working, any solutions?
Upvotes: 0
Views: 2612