【问题标题】:Active Choices plugin - not found referenced parameterActive Choices 插件 - 未找到引用的参数
【发布时间】: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)

【问题讨论】:

    标签: jenkins jenkins-plugins


    【解决方案1】:

    很遗憾,我无法对您的帖子发表评论以进行进一步澄清,因此我必须将其作为答案。您是否从 Active Choices Reactive Parameter 中填写了Referenced parameters

    在设置了初始的主动选择参数后,你必须在主动选择反应参数(就在选择类型下面)中通过填写初始主动选择参数的名称来引用它。我没有在你的打印屏幕上看到那个。

    告诉我。我希望这会有所帮助。

    更新: 没关系。我会自己回答。我刚刚看到你确实引用了它。我的错。还看到了来自 Jenkins 的错误报告:http://jenkins-ci.361315.n4.nabble.com/Active-Choices-plugin-not-found-referenced-parameter-td4890493.html

    就像 Ioannis Moutsatsos-2 所说,您应该尝试从 groovy 脚本中返回一个列表或地图,而不是您现在正在尝试的文本。

    【讨论】:

    • 您应该通过编辑添加实际答案,而不是作为评论。顺便说一句,欢迎来到 SO :)
    • 完成。感谢您的提示:)
    猜你喜欢
    • 2019-04-25
    • 1970-01-01
    • 1970-01-01
    • 2016-01-18
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    相关资源
    最近更新 更多