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

Snippet editor: Invalid code for "choice" parameter/properties

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None
    • pipeline:2.4

      Given I use Snippet Editor to generate code for the properties step and
      I select This project is parameterized and
      I add a new Choice Parameter
      When I enter the choices into the text area separated by line breaks and hit the Generate Pipeline Script button
      Then the emitted code includes choices: ['A', 'B', 'C'], which, however, is invalid.

      The resulting error message is:

      java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList

      Instead, the valid code would be choices: ['A\nB\nC'].

          [JENKINS-40358] Snippet editor: Invalid code for "choice" parameter/properties

          Mark Sun added a comment -

          hi Steffen, I try the code choices: ['A\nB\nC']
          but also got the error:
          java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList
          Instead, it's worked when I use code choices: 'A\nB\nC' .
          My jenkins version is 2.32.1

          Mark Sun added a comment - hi Steffen, I try the code choices: ['A\nB\nC'] but also got the error: java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.ArrayList Instead, it's worked when I use code choices: 'A\nB\nC' . My jenkins version is 2.32.1

            danielbeck Daniel Beck
            stephenking Steffen Gebert
            Votes:
            5 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: