gpt4 book ai didi

具有扩展选择参数的 Jenkins 声明式管道

转载 作者:行者123 更新时间:2023-12-04 06:27:13 24 4
gpt4 key购买 nike

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

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

在插件页面: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-syntaxSample step下拉选择 properties有一个复选框 This project is parameterized那么你可以选择Add parameter Extended Choice Parameter你可以为你的管道生成groovy。

关于具有扩展选择参数的 Jenkins 声明式管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44518963/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com