我尝试使用 Jenkins 实现我的第一个声明式管道,以便能够将作业的参数定义也放在 SCM 下。
我想转移具有扩展选择参数的现有作业。不幸的是,我无法将其添加到脚本的parameters{...} 部分。
在插件页面上:https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin 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]
不幸的是这对我不起作用。 “输入请求”给出了未指定的错误。虽然我可以接受“输入消息”解决方案,但这并不是我最初想要的。我想将此参数添加到已经提到的参数部分。但我找不到任何描述这一点的地方。有什么建议如何继续,或者还有替代方法/插件?
你应该去你的http://jenkins-url.com/pipeline-syntax
on the Sample step
下拉选择properties
有一个复选框This project is parameterized
然后你可以选择Add parameter
Extended Choice Parameter
您可以为您的管道生成常规。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)