【发布时间】:2017-03-13 15:15:05
【问题描述】:
我正在尝试使用 Active Choices 插件通过 github api 通过 repo 获取分支列表,但它给了我一个错误,即没有 repo - 这是一个已定义的引用参数。
如果我使用的是 Ubuntu 16.0.4、Jenkins 2.32.2 和 Active Choices 插件 1.5.3。
if (REPO.equals("REPOA")){
def proc = "curl https://api.github.com/repos/jenkinsci/active-choices-plugin/branches | jq -r '[.[] | .name ]'".execute()
return proc.text
}
else if (REPO.equals("REPOB")){
def proc = "curl https://api.github.com/repos/jenkinsci/active-choices-plugin/branches | jq -r '[.[] | .name ]' ".execute()
return proc.text
}
我是不是做错了什么?
(我也尝试使用缓冲区/流方式,因为我从 stackoverflow 中找到了一些关于不使用“文本”的答案,但结果相同。获取分支名称的代码部分在脚本编辑模式下工作正常。)
def proc ="curl...."
def outputStream = new StringBuffer()
proc.waitForProcessOutput(outputStream, System.err)
return outputStream.toString())
referenced parameter reactive part
错误如下:
Fallback to default script...
groovy.lang.MissingPropertyException: No such property: REPO for class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at Script1.run(Script1.groovy:1)
【问题讨论】: