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

Input "ChoiceParameterDefinition" with same name make the UI bug (select wrong choice when clicked)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reopened (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: blueocean-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.170
      BlueOcean 1.14
    • Similar Issues:

      Description

      I'm using BlueOcean with declarative Pipelines. In one of my pipeline there is a step which executes a Jenkins "script" in which there is a jenkins "input" using parameter type "ChoiceParameterDefinition". It reads the choices from a variable which contains multiple lines : 

       

      steps {
         script {
         def userInput = input(
            id: 'userInput', message: "mytest",
                parameters: [ 
                [$class: 'ChoiceParameterDefinition', choices: "${VAR_1}", name: 'config']
                ])
      VAR_2 = "${userInput}"           
           }
      } 

       

      When there are choices composed of the exact same string, the UI bugs. The user is prompted with a choice list but when he clicks on the first choice it selects the second one and vice versa. 

      I came accross this bug when I was doing some testings with the same string in each line of the variable. I'm not sure there is a real use case where you would like to have the choice between the "same" options but it should be easy to fix with at least an error saying that you can't have two choices which are the same for 'ChoiceParameterDefinition'.
      Please find an attached screenshot where I clicked the first choice and it selected the second one.

        Attachments

          Activity

          Hide
          halkeye Gavin Mogan added a comment -

          I'm not sure what the problem is here, the example you have doesn't work on its own.

          I got as far as 

            
          pipeline {
              agent any
              stages {
                  stage("Hello") {
                      steps {
                          script {
                              def userInput = input(
                                id: 'userInput', message: "mytest",
                                    parameters: [ 
                                    [$class: 'ChoiceParameterDefinition', choices: "${VAR_1}", name: 'config']
                                    ])
                              VAR_2 = "${userInput}"           
                          }
                      }
                  }
              }
          }  

          but thats missing VAR_1

          Is this using declarative syntax? or the other one. 

          I tried reproducing it on ci.blueocean.io but couldn't (set var_1 to "a\nb\nc\n")

           

          https://ci.blueocean.io/blue/organizations/jenkins/Gavin%20Folder%2FJENKINS-56977%20-%20multiline%20choice/activity

          Show
          halkeye Gavin Mogan added a comment - I'm not sure what the problem is here, the example you have doesn't work on its own. I got as far as  pipeline { agent any stages { stage( "Hello" ) { steps { script { def userInput = input( id: 'userInput' , message: "mytest" , parameters: [ [$class: 'ChoiceParameterDefinition' , choices: "${VAR_1}" , name: 'config' ] ]) VAR_2 = "${userInput}" } } } } } but thats missing VAR_1 Is this using declarative syntax? or the other one.  I tried reproducing it on ci.blueocean.io but couldn't (set var_1 to "a\nb\nc\n")   https://ci.blueocean.io/blue/organizations/jenkins/Gavin%20Folder%2FJENKINS-56977%20-%20multiline%20choice/activity
          Hide
          halkeye Gavin Mogan added a comment -

          Feel free to re-open if you can provide a sample test case.

          Show
          halkeye Gavin Mogan added a comment - Feel free to re-open if you can provide a sample test case.
          Hide
          larkoie Larkoie added a comment - - edited

          Hi,

          The bug occurs when there are 2 items with the same name in your list.

          In your example if you set var_1 to "a\na\nc\n" you will see the bug.

          I know that having two items with the same name in a list is not really a "real life scenario" but I came across this bug while testing functionalities with dummy files and thought that it could be tested to throw an error instead of displaying these bugged select buttons.

           

          To answer your other question : yes i'm using the declarative syntax

          Show
          larkoie Larkoie added a comment - - edited Hi, The bug occurs when there are 2 items with the same name in your list. In your example if you set var_1 to "a\na\nc\n" you will see the bug. I know that having two items with the same name in a list is not really a "real life scenario" but I came across this bug while testing functionalities with dummy files and thought that it could be tested to throw an error instead of displaying these bugged select buttons.   To answer your other question : yes i'm using the declarative syntax
          Hide
          halkeye Gavin Mogan added a comment -

          Ah, thats how html works in the browser. I don't think its a scenario we need to support since as you said its not a real world example, but i guess it is still a bug.

          Show
          halkeye Gavin Mogan added a comment - Ah, thats how html works in the browser. I don't think its a scenario we need to support since as you said its not a real world example, but i guess it is still a bug.

            People

            • Assignee:
              Unassigned
              Reporter:
              larkoie Larkoie
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: