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

Snippet generator creates wrong input statement with ChoiceParameter

    XMLWordPrintable

Details

    Description

      Using Snippet Generator for creating an input statement with choice parameter you get next sentence:

      input message: 'Environment to Deploy', parameters: [[$class: 'ChoiceParameterDefinition', choices: ['local','pre'], description: '', name: 'environment']]
      

      But then when you execute the script you get next exception:

      java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:590)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:524)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:96)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:576)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.mapList(DescribableHelper.java:603)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.coerce(DescribableHelper.java:588)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.buildArguments(DescribableHelper.java:524)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.injectSetters(DescribableHelper.java:663)
      	at org.jenkinsci.plugins.workflow.structs.DescribableHelper.instantiate(DescribableHelper.java:98)
      	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:103)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:133)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:113)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15)
      	at WorkflowScript.run(WorkflowScript:1)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.Cont
      

      Attachments

        Issue Links

          Activity

            asotobueno Alex Soto created issue -
            asotobueno Alex Soto made changes -
            Field Original Value New Value
            Labels core workflow
            asotobueno Alex Soto made changes -
            Resolution Duplicate [ 3 ]
            Status Open [ 1 ] Closed [ 6 ]
            melvynromero Melvyn Romero added a comment -

            Use this example, for fix the error, it work perfectly:

            properties ([[$class: 'hudson.model.ParametersDefinitionProperty', parameterDefinitions: [[$class: 'hudson.model.ChoiceParameterDefinition', choices: 'Value1\nValue2' , description: '', name: 'unChoiceParameter']]]])

            melvynromero Melvyn Romero added a comment - Use this example, for fix the error, it work perfectly: properties ([[$class: 'hudson.model.ParametersDefinitionProperty', parameterDefinitions: [ [$class: 'hudson.model.ChoiceParameterDefinition', choices: 'Value1\nValue2' , description: '', name: 'unChoiceParameter'] ]]])
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 169166 ] JNJira + In-Review [ 209770 ]
            abayer Andrew Bayer made changes -
            Component/s pipeline-general [ 21692 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-plugin [ 18820 ]
            abayer Andrew Bayer made changes -
            Labels core workflow core pipeline workflow
            abayer Andrew Bayer made changes -
            Labels core pipeline workflow core pipeline
            danielbeck Daniel Beck made changes -
            Link This issue duplicates JENKINS-26143 [ JENKINS-26143 ]

            People

              jglick Jesse Glick
              asotobueno Alex Soto
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: