詹金斯选择参数传递给管道作业

当前,我有一个具有不同参数的管道作业,其中此参数之一是Choice参数。这是该作业参数的config.xml输出:

<hudson.model.ChoiceParameterDefinition>

<choices class="java.util.Arrays$ArrayList">

<a class="string-array">

<string>f1</string>

<string>f2</string>

<string>f3</string>

<string>f4</string>

</a>

</choices>

<name>WHERE</name>

<description>Something</description>

</hudson.model.ChoiceParameterDefinition>

现在,我可以通过传递字符串参数从管道调用此作业:

build job: "NameOfTheJob"", parameters:

[

[$class: 'StringParameterValue', name: 'BRANCH', value: "${BRANCH}"],

]

但是我无法为选择参数定义参数:

我尝试了以下方法:

build job: "NameOfTheJob"", parameters:

[

[$class: 'StringParameterValue', name: 'BRANCH', value: "${BRANCH}"],

[$class: 'ChoiceParameterValue', name: 'WHERE', value: 'F3'],

]

但这失败并显示以下错误:

java.lang.UnsupportedOperationException: no known implementation of class hudson.model.ParameterValue is named ChoiceParameterValue

因此问题是:如何在调用其他管道作业时定义选择参数:

build job: "NameOfTheJob"", parameters:

[

[$class: 'StringParameterValue', name: 'BRANCH', value: "${BRANCH}"],

[$class: '??????', ????],

]

有人有这样的例子吗?

回答:

我看过一个使用以下语法的工作示例:

build job:'NameOfTheJob', parameters: [

string(name: 'FirstOption', value: "test"),

string(name: 'AnotherOption', value: "test12")

]

基本上,不要以特殊的方式对待选择参数,只需将它们视为常规字符串参数即可。

以上是 詹金斯选择参数传递给管道作业 的全部内容, 来源链接: utcz.com/qa/400025.html

回到顶部