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

cascaded active choice Radio Boxes does not auto update

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • active-choices-plugin
    • None
    • Jenkins LTS 2.401.3
      active-choice plugin 2.7
    • 2.7.2

      Hello,

      I have a quite complex freestyle project which have 9 active choices element on it. With the previous plugin version: 2.6.5 everything was worked as expected. Here is the controls / variable description:

      1) Active Choices Reactive Parameter #1 (Groovy Script)
      INPUT: VARIABLE1 (Choice Parameter), VARIABLE2 (Choice Parameter)
      OUTPUT: VARIABLE3 (Radio Buttons)

      2) Active Choices Reactive Parameter #2 (Groovy Script)
      INPUT: VARIABLE1 (Choice Parameter), VARIABLE2 (Choice Parameter), VARIABLE3 (Active Choices Reactive Parameter #1)
      OUTPUT: VARIABLE4 (Single Select)

      3) Active Choices Reactive Reference Parameter #3 (Groovy Script)
      INPUT: VARIABLE1 (Choice Parameter)
      OUTPUT: VARIABLE5 (Single Select)

      4) Active Choices Reactive Reference Parameter #4 (Groovy Script)
      INPUT: VARIABLE1 (Choice Parameter), VARIABLE2 (Choice Parameter), VARIABLE4 (Single Select)
      OUTPUT: VARIABLE6 (Formatted HTML: <input name=\"value\" value=\"${dynRefParam}\" class=\"setting-input\" type=\"text\">)

      5) Active Choices Reactive Parameter #5 (Groovy Script)
      INPUT: VARIABLE7 (Boolean Parameter)
      OUTPUT: VARIABLE8 (Multi Select)

      6) Active Choices Reactive Parameter #6 (Groovy Script)
      INPUT: VARIABLE1 (Choice Parameter), VARIABLE2 (Choice Parameter), VARIABLE3 (Radio Buttons), VARIABLE4 (Single Select)
      OUTPUT: VARIABLE9 (Check Boxes)

      7) Active Choices Reactive Parameter #7 (Groovy Script)
      INPUT: VARIABLE9 (Check Boxes)
      OUTPUT: VARIABLE10 (Radio Buttons)

      8) Active Choices Reactive Parameter #8 (Groovy Script)
      INPUT: VARIABLE1 (Choice Parameter), VARIABLE2 (Choice Parameter), VARIABLE4 (Single Select), VARIABLE7 (Boolean Parameter), VARIABLE10 (Radio Buttons)
      OUTPUT: VARIABLE11 (Radio Buttons)

      9) Active Choices Reactive Parameter #9 (Groovy Script)
      INPUT: VARIABLE2 (Choice Parameter)
      OUTPUT: VARIABLE12 (Check Boxes)

       

       

      where the #7 active choice does not get automatically updated with the correct input parameters. The input parameter: VARIABLE9 contains just 1 element for the specific faulty case

      Not all the active choices elements are involved in the decision of the returned value of the #7 element, I just mentioned it to have a complete picture for the task configuration.

       

      Let me known if any more description is required or if I can make some further investigations.

       

          [JENKINS-71724] cascaded active choice Radio Boxes does not auto update

          Jozsef created issue -

          Jason added a comment - - edited

          I had the same issue with cascading Select boxes that had a complex dependency after upgrading to 2.7.  I have not gotten around to putting together a simplified test case and making a report, but I did notice that going into the config and saving allowed it to work once, then after that first build the problem would be back.  The save caused the config to be updated from 2.65 to 2.7, with some additional elements, but next (successful) build resulted in another config update where the randomName entries were all updated, which I guess breaks the scripts linking all the ActiveChoices to each other.

          Jason added a comment - - edited I had the same issue with cascading Select boxes that had a complex dependency after upgrading to 2.7.  I have not gotten around to putting together a simplified test case and making a report, but I did notice that going into the config and saving allowed it to work once, then after that first build the problem would be back.  The save caused the config to be updated from 2.65 to 2.7, with some additional elements, but next (successful) build resulted in another config update where the randomName entries were all updated, which I guess breaks the scripts linking all the ActiveChoices to each other.
          efo plo made changes -
          Attachment New: screenshot-1.png [ 60912 ]
          efo plo made changes -
          Attachment New: screenshot-2.png [ 60913 ]

          efo plo added a comment -

          Have the same issue after upgrading to 2.7.

          Code:

          properties([
              parameters([
                  [$class: 'ChoiceParameterDefinition',
                      name: 'MACHINE_TYPE',
                      choices: ['Choose MACHINE_TYPE'] + (nodes_configuration.keySet() as List),
                      description: 'Please select the machine type.',
                  ],
                  [$class: 'CascadeChoiceParameter',
                      name: 'LEASE_TIME',
                      choiceType: 'PT_SINGLE_SELECT',
                      description: 'Hours to keep the machine',
                      referencedParameters: 'MACHINE_TYPE',
                      script:
                          [$class: 'GroovyScript',
                              fallbackScript:
                                  [classpath: [],
                                  sandbox: false,
                                  script: ''],
                              script:
                                  [classpath: [],
                                  sandbox: false,
                                  script: lease_choices_by_group()]
                          ]
                  ],
          ...
          def lease_choices_by_group() { 
              // slightly edited from real text
              return """if (MACHINE_TYPE == 'Choose MACHINE_TYPE')
                  return ['Please choose MACHINE_TYPE first']
                  else
                      return ['1', '2', '3', '4', '5', '6', '7', '8', '24', '48', '720']"""
          }
          
          

          Old version (Jenkins: Jenkins 2.387.2, Active Choices Plug-in: 2.6.5)

          New version (Jenkins: Jenkins 2.401.3, Active Choices Plug-in: 2.7)

          Old version Javascript console:

          [Log] Updating cascade of parameter [HEADING_FRONTEND_HIDDEN] ... (build, line 1186)
          [Log] Values retrieved from Referenced Parameters:  (unochoice.js, line 607)
          [Log] Could not find element by name, perhaps it is a DIV? (build, line 1222)
          [Log] Updating cascade of parameter [LEASE_TIME] ... (build, line 1269)
          [Log] Values retrieved from Referenced Parameters: MACHINE_TYPE=Choose MACHINE_TYPE (unochoice.js, line 148)
          [Log] Calling Java server code to update HTML elements... (unochoice.js, line 154)
          [Log] Values returned from server: [["Please choose MACHINE_TYPE first"],["Please choose MACHINE_TYPE first"]] (unochoice.js, line 157)
          [Log] Cascading changes from parameter MACHINE_TYPE... (unochoice.js, line 550)
          [Log] Values retrieved from Referenced Parameters: MACHINE_TYPE=tiny (unochoice.js, line 148)
          [Log] Calling Java server code to update HTML elements... (unochoice.js, line 154)
          [Log] Values returned from server: [["1","2","3","4","5","6","7","8","720"],["1","2","3","4","5","6","7","8","720"]] (unochoice.js, line 157)
          [Log] Cascading changes from parameter MACHINE_TYPE... (unochoice.js, line 550)
          

          New version Javascript console:

          [Error] Failed to load resource: the server responded with a status of 405 (Method Not Allowed) (build, line 0)
          [Log] Updating cascade of parameter [ – "HEADING_FRONTEND_HIDDEN""] ..." (UnoChoice.js, line 1)
          [Log] Values retrieved from Referenced Parameters:  (UnoChoice.js, line 1)
          [Error] SyntaxError: Unexpected token ','
          	(anonymous function) (build:1067)
          [Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (UnoChoice.js.map, line 0)
          

          Sources:

                  dynamicReferenceParameter = makeStaplerProxy('/$stapler/bound/c864c2c7-9883-4680-a7d9-5432470dcdd3', '52ea45d1bfcc4feced7cf74a5c96b9b5452986ed6e2926fcbe39772dbe0f627c', ['getChoicesAsStringForUI', 'getChoicesForUI', 'doUpdate']);
                                  </script>
                                  <script type="text/javascript">
                                  // source, references table
                                  var referencedParameters = Array();
          
          
          >>>                        UnoChoice.renderDynamicRenderParameter('#choice-parameter-12948928667198118', 'HEADING_FRONTEND_HIDDEN', 'choice-parameter-12948928667198118', referencedParameters, dynamicReferenceParameter);
                                  </script>
          

          Error:

          Unexpected token ','
          

          efo plo added a comment - Have the same issue after upgrading to 2.7. Code: properties([ parameters([ [$class: 'ChoiceParameterDefinition' , name: 'MACHINE_TYPE' , choices: [ 'Choose MACHINE_TYPE' ] + (nodes_configuration.keySet() as List), description: 'Please select the machine type.' , ], [$class: 'CascadeChoiceParameter' , name: 'LEASE_TIME' , choiceType: 'PT_SINGLE_SELECT' , description: 'Hours to keep the machine' , referencedParameters: 'MACHINE_TYPE' , script: [$class: 'GroovyScript' , fallbackScript: [classpath: [], sandbox: false , script: ''], script: [classpath: [], sandbox: false , script: lease_choices_by_group()] ] ], ... def lease_choices_by_group() { // slightly edited from real text return """ if (MACHINE_TYPE == 'Choose MACHINE_TYPE' ) return [ 'Please choose MACHINE_TYPE first' ] else return [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '24' , '48' , '720' ]""" } Old version (Jenkins: Jenkins 2.387.2, Active Choices Plug-in: 2.6.5) New version (Jenkins: Jenkins 2.401.3, Active Choices Plug-in: 2.7) Old version Javascript console: [Log] Updating cascade of parameter [HEADING_FRONTEND_HIDDEN] ... (build, line 1186) [Log] Values retrieved from Referenced Parameters: (unochoice.js, line 607) [Log] Could not find element by name, perhaps it is a DIV? (build, line 1222) [Log] Updating cascade of parameter [LEASE_TIME] ... (build, line 1269) [Log] Values retrieved from Referenced Parameters: MACHINE_TYPE=Choose MACHINE_TYPE (unochoice.js, line 148) [Log] Calling Java server code to update HTML elements... (unochoice.js, line 154) [Log] Values returned from server: [[ "Please choose MACHINE_TYPE first" ],[ "Please choose MACHINE_TYPE first" ]] (unochoice.js, line 157) [Log] Cascading changes from parameter MACHINE_TYPE... (unochoice.js, line 550) [Log] Values retrieved from Referenced Parameters: MACHINE_TYPE=tiny (unochoice.js, line 148) [Log] Calling Java server code to update HTML elements... (unochoice.js, line 154) [Log] Values returned from server: [[ "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "720" ],[ "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "720" ]] (unochoice.js, line 157) [Log] Cascading changes from parameter MACHINE_TYPE... (unochoice.js, line 550) New version Javascript console: [Error] Failed to load resource: the server responded with a status of 405 (Method Not Allowed) (build, line 0) [Log] Updating cascade of parameter [ – "HEADING_FRONTEND_HIDDEN" – "] ..." (UnoChoice.js, line 1) [Log] Values retrieved from Referenced Parameters: (UnoChoice.js, line 1) [Error] SyntaxError: Unexpected token ',' (anonymous function) (build:1067) [Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (UnoChoice.js.map, line 0) Sources: dynamicReferenceParameter = makeStaplerProxy( '/$stapler/bound/c864c2c7-9883-4680-a7d9-5432470dcdd3' , '52ea45d1bfcc4feced7cf74a5c96b9b5452986ed6e2926fcbe39772dbe0f627c' , [ 'getChoicesAsStringForUI' , 'getChoicesForUI' , 'doUpdate' ]); </script> <script type= "text/javascript" > // source, references table var referencedParameters = Array(); >>> UnoChoice.renderDynamicRenderParameter( '#choice-parameter-12948928667198118' , 'HEADING_FRONTEND_HIDDEN' , 'choice-parameter-12948928667198118' , referencedParameters, dynamicReferenceParameter); </script> Error: Unexpected token ','

          efo plo added a comment -

          I can add that downgrading to 2.6.5 solved the issue for us.
          Jenkins: Jenkins 2.401.3, Active Choices Plug-in: 2.7: issue!
          Jenkins: Jenkins 2.401.3, Active Choices Plug-in: 2.6.5: no issue.

          kinow May I humbly suggest, as a temporary measure, to pull 2.7 release in order to prevent breaking stuff.

          efo plo added a comment - I can add that downgrading to 2.6.5 solved the issue for us. Jenkins: Jenkins 2.401.3, Active Choices Plug-in: 2.7: issue! Jenkins: Jenkins 2.401.3, Active Choices Plug-in: 2.6.5: no issue. kinow May I humbly suggest, as a temporary measure, to pull 2.7 release in order to prevent breaking stuff.

          Hi jasonr 

          >I have not gotten around to putting together a simplified test case and making a report

          That would be helpful, and we can make a test case (junit or selenium) to avoid future regressions.

          >but I did notice that going into the config and saving allowed it to work once, then after that first build the problem would be back.  The save caused the config to be updated from 2.65 to 2.7, with some additional elements, but next (successful) build resulted in another config update where the randomName entries were all updated, which I guess breaks the scripts linking all the ActiveChoices to each other.

          Hmm, looks like we forgot to handle de/serialization for new constructor/getter-setter somewhere.

          Bruno P. Kinoshita added a comment - Hi jasonr   >I have not gotten around to putting together a simplified test case and making a report That would be helpful, and we can make a test case (junit or selenium) to avoid future regressions. >but I did notice that going into the config and saving allowed it to work once, then after that first build the problem would be back.  The save caused the config to be updated from 2.65 to 2.7, with some additional elements, but next (successful) build resulted in another config update where the randomName entries were all updated, which I guess breaks the scripts linking all the ActiveChoices to each other. Hmm, looks like we forgot to handle de/serialization for new constructor/getter-setter somewhere.

          Hi eplodn1 

          >kinow May I humbly suggest, as a temporary measure, to pull 2.7 release in order to prevent breaking stuff.

          I don't know if that'd be simple with Jenkins (with Maven central it would be a little difficult).

          Not sure if it's breaking every installation as well (maybe it works with some combination of settings, some automation in place that by chance works, new users, etc.).

          So another alternative could be to fix in 2.7.1 whatever is broken when going from 2.6 to 2.7 (if that's really the problem), so users can now pick 2.6 -> 2.7.1, or even 2.6 -> 2.7 and then upon finding the issue go to 2.7.1.

          That shouldn't break their envs, and would allow upgrades without having to ditch versions in Jenkins central site.

          The SyntaxError you reported looks serious, but this issue appears to be about another issue with 2.7.

          Bruno P. Kinoshita added a comment - Hi eplodn1   > kinow May I humbly suggest, as a temporary measure, to pull 2.7 release in order to prevent breaking stuff. I don't know if that'd be simple with Jenkins (with Maven central it would be a little difficult). Not sure if it's breaking every installation as well (maybe it works with some combination of settings, some automation in place that by chance works, new users, etc.). So another alternative could be to fix in 2.7.1 whatever is broken when going from 2.6 to 2.7 (if that's really the problem), so users can now pick 2.6 -> 2.7.1, or even 2.6 -> 2.7 and then upon finding the issue go to 2.7.1. That shouldn't break their envs, and would allow upgrades without having to ditch versions in Jenkins central site. The SyntaxError you reported looks serious, but this issue appears to be about another issue with 2.7.

          efo plo added a comment - - edited

          kinow Thanks for reply.

          Here is the minimal pipeline that (after script approval) works for me ok on 2.6.5 but has an issue on 2.7.
          The 2.7 is behaving strange because after entering the Configure page it sometimes manages to show the data.

          properties([
              parameters([
                  [$class: 'ChoiceParameterDefinition',
                      name: 'MACHINE_TYPE',
                      choices: ['Choose MACHINE_TYPE', "tiny", "small"],
                  ],
                  [$class: 'CascadeChoiceParameter',
                      name: 'LEASE_TIME',
                      choiceType: 'PT_SINGLE_SELECT',
                      referencedParameters: 'MACHINE_TYPE',
                      script:
                          [$class: 'GroovyScript',
                              fallbackScript: [classpath: [], sandbox: false, script: ''],
                              script: [classpath: [], sandbox: false, script: get_choices()]
                          ]
                  ],
          
              ])
          ])
          
          pipeline {
              agent { node { label "master || built-in" } }
              
              stages {
                  stage('1') {
                      steps {
                          script {
                              echo "Got ${params.MACHINE_TYPE} for ${params.LEASE_TIME} minutes"
                          }
                      }
                  }
              }
          }
          
          
          def get_choices() {
              return """if (MACHINE_TYPE == 'Choose MACHINE_TYPE')
                  return ['Please choose MACHINE_TYPE first']
              else
                  return ['1', '2', '3', '4', '5', '6', '7', '8', '24', '48', '720']"""
          }
          

          Error is here:

                                  <script type="text/javascript">
                                      // source, references table
                                      var referencedParameters = Array();
                                      // add the element we want to monitor
                                          referencedParameters.push("MACHINE_TYPE");
          
                                      UnoChoice.renderCascadeChoiceParameter('#choice-parameter-14259837002684041', , 'LEASE_TIME', 'choice-parameter-14259837002684041', 1, 'choice-parameter-14259837002684041', referencedParameters, cascadeChoiceParameter);
          
                                    </script>
          

          When it fails, I get the following error in addition to "Unexpected token" (not sure if relevant):

          https://<jenkins-url>/adjuncts/3262e2e0/org/biouno/unochoice/stapler/unochoice/UnoChoice.js.map
          HTTP ERROR 403 Forbidden
          URI:	/adjuncts/3262e2e0/org/biouno/unochoice/stapler/unochoice/UnoChoice.js.map
          STATUS:	403
          MESSAGE:	Forbidden
          SERVLET:	Stapler
          Powered by Jetty:// 10.0.13
          

          efo plo added a comment - - edited kinow Thanks for reply. Here is the minimal pipeline that (after script approval) works for me ok on 2.6.5 but has an issue on 2.7. The 2.7 is behaving strange because after entering the Configure page it sometimes manages to show the data. properties([ parameters([ [$class: 'ChoiceParameterDefinition' , name: 'MACHINE_TYPE' , choices: [ 'Choose MACHINE_TYPE' , "tiny" , "small" ], ], [$class: 'CascadeChoiceParameter' , name: 'LEASE_TIME' , choiceType: 'PT_SINGLE_SELECT' , referencedParameters: 'MACHINE_TYPE' , script: [$class: 'GroovyScript' , fallbackScript: [classpath: [], sandbox: false , script: ''], script: [classpath: [], sandbox: false , script: get_choices()] ] ], ]) ]) pipeline { agent { node { label "master || built-in" } } stages { stage( '1' ) { steps { script { echo "Got ${params.MACHINE_TYPE} for ${params.LEASE_TIME} minutes" } } } } } def get_choices() { return """ if (MACHINE_TYPE == 'Choose MACHINE_TYPE' ) return [ 'Please choose MACHINE_TYPE first' ] else return [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '24' , '48' , '720' ]""" } Error is here: <script type= "text/javascript" > // source, references table var referencedParameters = Array(); // add the element we want to monitor referencedParameters.push( "MACHINE_TYPE" ); UnoChoice.renderCascadeChoiceParameter( '#choice-parameter-14259837002684041' , , 'LEASE_TIME' , 'choice-parameter-14259837002684041' , 1, 'choice-parameter-14259837002684041' , referencedParameters, cascadeChoiceParameter); </script> When it fails, I get the following error in addition to "Unexpected token" (not sure if relevant): https: //<jenkins-url>/adjuncts/3262e2e0/org/biouno/unochoice/stapler/unochoice/UnoChoice.js.map HTTP ERROR 403 Forbidden URI: /adjuncts/3262e2e0/org/biouno/unochoice/stapler/unochoice/UnoChoice.js.map STATUS: 403 MESSAGE: Forbidden SERVLET: Stapler Powered by Jetty: // 10.0.13

          Rahul Somasunderam added a comment - - edited

          I was able to reproduce this. Many thanks for the pipeline example.
          The problem seems to be that `filterable` is `Boolean` and shows up as `null` so it doesn't get passed down. Is it possible to set it to `false` explicitly?

                  [$class: 'CascadeChoiceParameter',
                      name: 'LEASE_TIME',
                      choiceType: 'PT_SINGLE_SELECT',
                      referencedParameters: 'MACHINE_TYPE',
                      filterable: false,
                      script:
                          [$class: 'GroovyScript',
                              fallbackScript: [classpath: [], sandbox: false, script: ''],
                              script: [classpath: [], sandbox: false, script: get_choices()]
                          ]
                  ],
          

          Rahul Somasunderam added a comment - - edited I was able to reproduce this. Many thanks for the pipeline example. The problem seems to be that `filterable` is `Boolean` and shows up as `null` so it doesn't get passed down. Is it possible to set it to `false` explicitly? [$class: 'CascadeChoiceParameter' , name: 'LEASE_TIME' , choiceType: 'PT_SINGLE_SELECT' , referencedParameters: 'MACHINE_TYPE' , filterable: false , script: [$class: 'GroovyScript' , fallbackScript: [classpath: [], sandbox: false , script: ''], script: [classpath: [], sandbox: false , script: get_choices()] ] ],

            rahulsom Rahul Somasunderam
            szjozsef Jozsef
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: