jenkins - 如何在 Jenkins 管道脚本中使用扩展选择参数插件?

标签 jenkins extended-choice-parameter

扩展选择参数插件很棒,我在通过 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 

有谁知道有什么解决方法可以解决不使用@DataBoundConstructorExtendedChoiceParameterDefinition问题吗?

  • 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/

相关文章:

Jenkins Pipeline Build Trigger with git pull,如何?

jenkins - 如何在扩展选择参数插件中获取Jenkins环境变量

postgresql - Jenkins 扩展选择插件 : Unable to fetch choices from postgres db

jenkins - 使用 Groovy 脚本获取给定目录中的所有文件夹(使用 Jenkins 中的扩展选择参数)

jenkins - 中止时如何使用 SIGINT 而不是 SIGTERM 终止 Jenkins 作业中的 psql 进程?

performance - AWS EC2 t2.micro 无限 | Jenkins Maven |很慢|构建挂起

maven - 如何取消部署与 Jenkins 的.war?

jenkins-pipeline - 在声明性 Jenkinsfile 之前运行脚本以使用扩展选择参数插件

jenkins - 为什么迭代列表时需要@NonCPS?