目前我有一个管道作业,它有不同的参数,其中一个参数是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>现在,我可以通过传递一个字符串参数从管道via调用此作业:
build job: "NameOfTheJob"", parameters:
[
[$class: 'StringParameterValue', name: 'BRANCH', value: "${BRANCH}"],
]但是我不能得到一种方法来定义一个choice参数的参数:
我尝试过以下几种方法:
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: '??????', ????],
]有人举过这样的例子吗?
发布于 2021-01-25 19:46:23
您可以使用extendedChoice而不是ChoiceParameterValue,如下所示:
build job: 'NameOfTheJob', parameters: [extendedChoice(name: 'WHERE', value: 'F3')]詹金斯文档:https://www.jenkins.io/doc/pipeline/steps/pipeline-build-step/
https://stackoverflow.com/questions/41759405
复制相似问题