admin管理员组文章数量:1418380
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?
本文标签: jenkinsHow to access build Parameter value from Groovy scriptStack Overflow
版权声明:本文标题:jenkins - How to access build Parameter value from Groovy script - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745287643a2651594.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论