主动选择插件 - 找不到参考参数



我正在尝试使用Active Choices插件使用GitHub API获取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的"文本"的答案,但结果相同。获得分支名称的代码部分在Scriptler编辑模式下工作正常。)

def proc ="curl...."
def outputStream = new StringBuffer()
proc.waitForProcessOutput(outputStream, System.err)
return outputStream.toString())

引用参数反应性零件

错误如下:

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)

不幸的是,我无法在您的帖子中发表评论以进一步澄清,因此我必须将其作为答案。您是否从主动选择中填写了Referenced parameters反应性参数?

设置初始活动选择参数后,您必须通过填写初始活动选择参数的名称来反应性参数(只是bellow选择类型)中引用它。我在您的打印屏幕上没有看到它。

让我知道。我希望这会有所帮助。

更新:没关系。我会回答自己。我刚刚看到您确实提到了它。我的错。还看到了jenkins的错误报告:http://jenkins-ci.361315.n4.n4.n44.nabble.com/active-choices-plugin-not-not-found-round-round-round-parameter-td4890493.html

就像ioannis Moutsatsos-2所说,您应该尝试返回groovy脚本的列表或映射,而不是您现在尝试的文本。

最新更新