I have a Jenkins FreeStyle Project with choice parameter called "PROJECT".
In extensible choice parameter "OPTIONS" I want to load list of options from one of files depending on passed $PROJECT value (for example, if $PROJECT == "Project_A", then parameter "OPTIONS" should return options from "/var/lib/jenkins/files/Project_A.txt"). I use this Groovy script:
import hudson.model.*
// Get current thread / Executor
def thr = Thread.currentThread()
// Get current build and extract PROJECT value
def build = thr?.executable
def resolver = build.buildVariableResolver
def project = resolver.resolve("PROJECT")
// Construct the file path
def filePath = "/var/lib/jenkins/files/${project}.txt"
def file = new File(filePath)
// Read options
def options = []
file.eachLine { line ->
line = line.trim()
options.add(line)
}
// Return list of options
return options
But when I try to start a build there is no drop-down with options even though file contain values. Also I don't know how to debug since running script in Sand-box or in ScriptConsole returns
groovy.lang.MissingPropertyException: No such field found: field java.lang.Thread executable
What should be the correct Groovy script to extract "PROJECT" parameter value?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745287643a4620658.html
评论列表(0条)