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

Fail to generate correct input step with choice param syntax from snippet generator

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • pipeline
    • None

      Snippet generator generates this for input step with choice parameters:

      input message: '', parameters: [[$class: 'ChoiceParameterDefinition', choices: ['option1', 'option2'], description: '', name: 'My param']]
      

      That code tries to use the @DataboundConstructor of ChoiceParameterDefinition which does not match with the required signature, thus this warning stack trace is shown on snippet generation time:

      May 04, 2016 10:25:46 AM org.jenkinsci.plugins.structs.describable.DescribableModel uninstantiate
      WARNING: Cannot create control version of class hudson.model.ChoiceParameterDefinition using {choices=[option1, option2], description=, name=select}
      java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.Arrays$ArrayList
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:317)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:248)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:192)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate(DescribableModel.java:440)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:466)
      	at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:164)
      	at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:158)
      	at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:112)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate(DescribableModel.java:426)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:466)
      	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.defineArguments(StepDescriptor.java:114)
      	at org.jenkinsci.plugins.workflow.cps.Snippetizer.object2Groovy(Snippetizer.java:68)
      	at org.jenkinsci.plugins.workflow.cps.Snippetizer.doGenerateSnippet(Snippetizer.java:218)
      

      The generated snippet does not work later on runtime, throwing the same exception.

          [JENKINS-34590] Fail to generate correct input step with choice param syntax from snippet generator

          Antonio Muñiz created issue -

          Workaround: use this instead of the snippet generation code.

          choice = new ChoiceParameterDefinition('Param name', ['option1', 'option2'] as String[], 'Description')
          input message: 'Select one', parameters: [choice]
          

          Antonio Muñiz added a comment - Workaround: use this instead of the snippet generation code. choice = new ChoiceParameterDefinition( 'Param name' , [ 'option1' , 'option2' ] as String [], 'Description' ) input message: 'Select one' , parameters: [choice]

          Patrick Wolf added a comment - - edited

          I think this is a duplicate ticket that was already filed. Do you know the original ticket on this danielbeck?

          Is this the same issue?
          https://issues.jenkins-ci.org/browse/JENKINS-29711

          Patrick Wolf added a comment - - edited I think this is a duplicate ticket that was already filed. Do you know the original ticket on this danielbeck ? Is this the same issue? https://issues.jenkins-ci.org/browse/JENKINS-29711

          hrmpw I don't think so. This one is about the snippet generator picking up a wrong constructor.

          Antonio Muñiz added a comment - hrmpw I don't think so. This one is about the snippet generator picking up a wrong constructor.

          Daniel Beck added a comment -

          hrmpw No, this one is specific to the ChoiceParameterDefinition type and inconsistency in its definition. Looks more like JENKINS-26143.

          Daniel Beck added a comment - hrmpw No, this one is specific to the ChoiceParameterDefinition type and inconsistency in its definition. Looks more like JENKINS-26143 .

          Right, duplicated.

          Antonio Muñiz added a comment - Right, duplicated.
          Antonio Muñiz made changes -
          Link New: This issue duplicates JENKINS-26143 [ JENKINS-26143 ]
          Antonio Muñiz made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]
          Daniel Beck made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]
          Daniel Beck made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Reopened [ 4 ] New: Resolved [ 5 ]

            jglick Jesse Glick
            amuniz Antonio Muñiz
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: