Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-34617

Make extended-choice-parameter-plugin pipeline compatibility easier

      https://github.com/jenkinsci/extended-choice-parameter-plugin/blob/master/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java#L427

      should implement @DataboundConstructor to support snippet generator. Or a new constructor should be supplied allowing for some sensible defaults. Just an idea.

      Usage with pipeline is currently possible but not very practical. The number of parameters required for the current constructor is pretty huge.

          [JENKINS-34617] Make extended-choice-parameter-plugin pipeline compatibility easier

          vimil added a comment -

          could you send me a pull request with the changes you'd like to see?

          vimil added a comment - could you send me a pull request with the changes you'd like to see?

          Owen Wood added a comment -

          Had a go at this. Looks like this plugin might need a bit of an overhaul to work correctly with @DataBoundConstructor. Interested in anyone who has some idea's of other approaches.

          Owen Wood added a comment - Had a go at this. Looks like this plugin might need a bit of an overhaul to work correctly with @DataBoundConstructor . Interested in anyone who has some idea's of other approaches.

          Sakti Mishra added a comment -

          Hello All,

          I do face same issue while using "Extended Choice Parameter" in pipeline input step. Below is the input step code I use

          [$class: 'com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition', quoteValue:false, type:'PT_CHECKBOX', multiSelectDelimiter:',', visibleItemCount:50, description:'',value: 'test1,test2', name: 'Target Environment']

          And below is error I get which is for same @DataBoundConstructor

          org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition
          at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:247)
          at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:121)
          at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:372)
          at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(DescribableModel.java:453)
          at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:357)
          at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:333)
          at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:259)
          at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:194)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181)
          at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
          at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
          at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
          at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
          at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
          at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
          at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
          at WorkflowScript.run(WorkflowScript:45)
          at __cps.transform__(Native Method)
          at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
          at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
          at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
          at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
          at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
          at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
          at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
          at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
          at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
          at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
          at com.cloudbees.groovy.cps.Next.step(Next.java:58)
          at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
          at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
          at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
          at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
          at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
          at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)
          Finished: FAILURE

          Sakti Mishra added a comment - Hello All, I do face same issue while using "Extended Choice Parameter" in pipeline input step. Below is the input step code I use [$class: 'com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition', quoteValue:false, type:'PT_CHECKBOX', multiSelectDelimiter:',', visibleItemCount:50, description:'',value: 'test1,test2', name: 'Target Environment'] And below is error I get which is for same @DataBoundConstructor org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:247) at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:121) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:372) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(DescribableModel.java:453) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:357) at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:333) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:259) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:194) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16) at WorkflowScript.run(WorkflowScript:45) at __ cps.transform __(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82) at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55) at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45) at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55) at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45) at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55) at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45) at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:58) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Finished: FAILURE

          Mike Kobit added a comment -

          Any progress on this? owood what problems did you have when trying to implement this before?

          It sounds mostly straightforward on the DEVGUIDE, but this plugin could be more complicated.

          Mike Kobit added a comment - Any progress on this? owood what problems did you have when trying to implement this before? It sounds mostly straightforward on the  DEVGUIDE , but this plugin could be more complicated.

          Owen Wood added a comment -

          mkobit honestly cant remember exactly what the issue was. It was May last year when I looked at this. 

           

          My recommendation is to look at the code.

          Owen Wood added a comment - mkobit honestly cant remember exactly what the issue was. It was May last year when I looked at this.    My recommendation is to look at the code.

          FYI here is a snippet of how to declare a parameter in a Jenkinsfile by manually instanciating a ` com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition`

          https://gist.github.com/jgraglia/44a7443847cff6f0d87387a46c7bb82f

          Julien Graglia added a comment - FYI here is a snippet of how to declare a parameter in a Jenkinsfile by manually instanciating a ` com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition` https://gist.github.com/jgraglia/44a7443847cff6f0d87387a46c7bb82f

          Sakti, I was able to use Julien's less-than-pretty example. You can feed "test" right into input(). Out came a comma-separated list exactly as I needed. My users can now delete dead Docker containers.

          Aaron D. Marasco added a comment - Sakti, I was able to use Julien's less-than-pretty example. You can feed " test " right into input() . Out came a comma-separated list exactly as I needed. My users can now delete dead Docker containers.

          Yves Schumann added a comment -

          Any progress here? The plugin is very important as we use it to reference generated properties files to select build parameters!

          Yves Schumann added a comment - Any progress here? The plugin is very important as we use it to reference generated properties files to select build parameters!

          Craig Rodrigues added a comment - - edited

          I have a patch which allows you to specify **extendedChoice in the parameters block of a declarative pipeline.

          https://github.com/jenkinsci/extended-choice-parameter-plugin/pull/25

          Craig Rodrigues added a comment - - edited I have a patch which allows you to specify ** extendedChoice in the parameters block of a declarative pipeline. https://github.com/jenkinsci/extended-choice-parameter-plugin/pull/25

            vimil vimil
            owood Owen Wood
            Votes:
            15 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated: