如何在Jenkins管道脚本中使用扩展选择参数插件? [英] How can I use the Extended Choice Parameter plugin in a Jenkins pipeline script?
问题描述
扩展选择参数插件很棒,我在通过UI https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin
The Extended Choice Parameter plugin is great and I use it in jobs configured via the UI https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin
但是,我正在努力使其以Jenkinsfile
样式的管道脚本运行.
由于Jenkins管道语法生成器创建了以下代码段,因此扩展选择参数插件似乎尚未与管道脚本完全兼容:
However, I'm struggling to get it working in a Jenkinsfile
style pipeline script.
It would appear that the Extended Choice Parameter plugin isn't yet fully compatible with Pipeline scripts since Jenkins pipeline-syntax generator creates the following snippet:
parameters([<object of type com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition>])
如果我手动创建参数,我将得到与所述相同的行为 https://issues.jenkins-ci.org/browse/JENKINS-32188
If I create the parameters manually I get the same behavior as mentioned in https://issues.jenkins-ci.org/browse/JENKINS-32188
org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class
有人知道不使用@DataBoundConstructor
可以解决ExtendedChoiceParameterDefinition
问题的任何解决方法吗?
Does anyone know of any workarounds that can get around the issue of ExtendedChoiceParameterDefinition
not using @DataBoundConstructor
?
- Jenkins 2.19.2
- 扩展选择参数插件0.75
推荐答案
自2019年4月2日以来,由于此提交,现在成为可能: https://github.com/jenkinsci/extended-choice-parameter-plugin/pull/25
Since April's 2nd, 2019 it's now possible because of this commit: https://github.com/jenkinsci/extended-choice-parameter-plugin/pull/25
例如,您可以像这样使用它:
You can use it like this for instance:
properties([
parameters([
extendedChoice(
name: 'PROJECT',
defaultValue: '',
description: 'Sélectionnez le projet à construire.',
type: 'PT_SINGLE_SELECT',
groovyScript: valueKeysScript,
descriptionGroovyScript: valueNamesScript
)
])
])
If you want to know every possible parameter you have to refer to the source code.
If you want to know every possible value for the "type" key, have a look at the PT_*
constants.
这篇关于如何在Jenkins管道脚本中使用扩展选择参数插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!