【问题标题】:Jenkins Declarative Pipeline with extended choice parameter具有扩展选择参数的 Jenkins 声明式管道
【发布时间】:2017-06-13 10:31:04
【问题描述】:

我尝试使用 Jenkins 实现我的第一个声明式管道,以便能够将作业的参数定义也放在 ​​SCM 下。

我想转移具有扩展选择参数的现有工作。不幸的是,我无法将其添加到脚本的参数{...} 部分。

在插件页面:https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin 我发现一条评论说应该可以通过:

import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition

def type = "PT_JSON"
def groovyScript  = null
def propertyValue  = null
def projectName = null
def propertyFile = null
def groovyScriptFile = "/path_to/script.groovy"
... 
def extendedChoice = new ExtendedChoiceParameterDefinition(name,
            type,
            propertyValue,
            projectName,
            propertyFile,
            groovyScript,
.....

input message: 'Param1', parameters: [extendedChoice]

不幸的是,这对我不起作用。 “输入请求”给出了一个未指定的错误。虽然我可以接受“输入消息”解决方案,但这并不是我首先要寻找的。如前所述,我想将此参数添加到参数部分。但我找不到任何描述这一点的地方。任何建议如何继续,或者可能还有替代方法/插件?

【问题讨论】:

    标签: jenkins jenkins-pipeline


    【解决方案1】:

    你应该去你的http://jenkins-url.com/pipeline-syntaxSample step下拉选择propertiesThis project is parameterized有一个复选框然后你可以选择Add parameterExtended Choice Parameter你可以为你的管道生成groovy .

    【讨论】:

    • 但这仅适用于“脚本化管道”而不适用于“声明性管道”还是我错了? ...即使它正在工作,它总是只生成: properties([parameters([]), pipelineTriggers([])])
    • 据说,我听说不支持扩展选择参数,他们的板上有一张关于它的票。但是我找不到它可以分享,如果我这样做了,我会告诉你的。
    【解决方案2】:

    这是我成功使用和测试的单个参数,您可能需要将其转换为 Json

    com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition extch =new com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition( "NAME", "PT_SINGLE_SELECT", "VALUE, a, b", null, null, null, null, null,null, null,null,null, null, null, null,null, null, null,null, null, null, null, null, null, null,null,false,false,2,"DESC", "," )
    

    【讨论】:

    • 感谢您。但感觉并不完全正确。我希望他们会在未来以某种方式支持它。所以仍然希望奇迹发生。
    • @Matthias,你了解更多了吗?我渴望在我的声明性管道中使用扩展选择参数,并且努力寻找关于最简单前进路径的好信息。
    • @timbaktu 没有什么新鲜事。对于我们非常复杂的参数,我们决定将 javascript 放在工作描述中,并在 JS 中实现我们自己的逻辑
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多