扩展选择参数插件很棒,我在通过 UI 配置的作业中使用它 https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin
但是,我正在努力让它在 Jenkinsfile 样式管道脚本中工作。 扩展选择参数插件似乎尚未与管道脚本完全兼容,因为 Jenkins 管道语法生成器创建了以下代码片段:
parameters([<object of type com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition>])
如果我手动创建参数,我会得到与中提到的相同的行为 https://issues.jenkins-ci.org/browse/JENKINS-32188
org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class
有谁知道有什么解决方法可以解决不使用@DataBoundConstructor
的ExtendedChoiceParameterDefinition
问题吗?
- Jenkins 2.19.2
- 扩展选择参数插件 0.75
最佳答案
自 2019 年 4 月 2 日以来,由于此提交,现在成为可能:https://github.com/jenkinsci/extended-choice-parameter-plugin/pull/25
您可以像这样使用它:
properties([
parameters([
extendedChoice(
name: 'PROJECT',
defaultValue: '',
description: 'Sélectionnez le projet à construire.',
type: 'PT_SINGLE_SELECT',
groovyScript: valueKeysScript,
descriptionGroovyScript: valueNamesScript
)
])
])
如果你想知道每个可能的参数,你必须 refer to the source code 。
如果您想知道“type”键的每个可能值,have a look at the PT_*
constants .
关于jenkins - 如何在 Jenkins 管道脚本中使用扩展选择参数插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42392247/