具有扩展选择参数的Jenkins声明式管道 [英] Jenkins Declarative Pipeline with extended choice parameter
问题描述
我尝试使用Jenkins实现我的第一个声明式管道,以便能够将作业的参数定义也置于SCM下.
I tried out to implement my first Declarative Pipeline with Jenkins to be able to put also the parameter definitions of a job under SCM.
我想转移具有扩展选择参数的现有工作.不幸的是,我无法将其添加到脚本的参数{...}部分.
I wanted to transfer an existing job that has an extended choice paraemter. Unfortunately I was not able to add it to the parameters{...} section of my script.
在插件页面上: https://wiki. jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin 我发现一条评论指出应该可以通过以下方式实现:
On the plugin page: https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin I found a comment that stated it should be possible by:
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]
不幸的是,这对我不起作用. 输入请求"给出了一个未指定的错误.虽然我可以使用输入消息"解决方案,但是这并不是我最初想要的.我想将此参数添加到参数部分,如前所述.但是我找不到任何描述它的地方.关于如何进行的任何建议,或者还有其他方法/插件?
Unfortunately this was not working for me. "input Requested" gave a non specified error. While I could live with an "input message" solution, it was not what I was looking for in the first place. I want to add this parameter to the parameter section as mentioned already. But I am not able to find any place where this is described. Any suggestions how to go on, or maybe also alternative approaches/plugins?
推荐答案
您应该在Sample step
下拉列表中转到http://jenkins-url.com/pipeline-syntax
,选择properties
有一个This project is parameterized
复选框,然后您可以选择Add parameter
Extended Choice Parameter
,您可以为此为管道生成Groovy.
You should go to your http://jenkins-url.com/pipeline-syntax
on the Sample step
dropdown select properties
There is a checkbox for This project is parameterized
then you can select Add parameter
Extended Choice Parameter
and you can generate the groovy for that for your pipeline.
这篇关于具有扩展选择参数的Jenkins声明式管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!