V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
guanzhangzhang
V2EX  ›  Java

jenkins groovy 怎么透传参数给插件的 class new 的时候

  •  
  •   guanzhangzhang ·
    zhangguanzhang · 10 天前 · 422 次点击

    https://github.com/jenkinsci/extended-choice-parameter-plugin/pull/25 这个扩展选择参数的插件,发现不能像评论那样使用:

        extendedChoice( 
            defaultValue: 'One,Two,Three,Four', 
            description: '', 
            multiSelectDelimiter: ',', 
            name: 'SAMPLE_EXTENDED_CHOICE', 
            quoteValue: false, 
            saveJSONParameterToFile: false, 
            type: 'PT_CHECKBOX', 
            value:'One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten', 
            visibleItemCount: 10)
    

    我只能下面这样封装下后可以使用

    def extendedChoice(Map params){
    
        def visibleItemCount = params.visibleItemCount ?: params.values.split(',').size()
        return new ExtendedChoiceParameterDefinition(
            params.name, //name,
            params.type, //type
            params.value, //value
            "", //projectName
            "", //propertyFile
            "", //groovyScript
            "", //groovyScriptFile
            "", //bindings
            "", //groovyClasspath
            "", //propertyKey
            params.defaultValue, //defaultValue
            "", //defaultPropertyFile
            "", //defaultGroovyScript
            "", //defaultGroovyScriptFile
            "", //defaultBindings
            "", //defaultGroovyClasspath
            "", //defaultPropertyKey
            "", //descriptionPropertyValue
            "", //descriptionPropertyFile
            "", //descriptionGroovyScript
            "", //descriptionGroovyScriptFile
            "", //descriptionBindings
            "", //descriptionGroovyClasspath
            "", //descriptionPropertyKey
            "", //javascriptFile
            "", //javascript
            false, //saveJSONParameterToFile
            false, //quoteValue
            visibleItemCount, //visibleItemCount
            params.description, //description
            params.multiSelectDelimiter //multiSelectDelimiter
        )
    }
    

    有没有啥两三行的传递,类似:

    def extendedChoice(params){
      return new ExtendedChoiceParameterDefinition(params)
    } 
    

    我尝试了

    def extendedChoice(Map params){
      return new ExtendedChoiceParameterDefinition(params)
    } 
    

    执行报错

    java.lang.SecurityException: Unable to find constructor: new com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition java.util.LinkedHashMap
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   877 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 19:24 · PVG 03:24 · LAX 12:24 · JFK 15:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.