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

active choice updates in wrong order (does not Cascade the values correctly)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • active-choices-plugin
    • None
    • clean jenkins docker latest LTS: 2.414.3, with the recommended plugins + active-choice plugin(2.8.0) installed

      With the new version of the active-choice plugin 2.7.1, 2.7.2, 2.8.0, 2.8.1 the recursive update of the elements are not always working as expected. This working just fine with the previous release 2.6.5

      With the latest LTS jenkins version 2.426.1 the issue is still present, also the old version of the plugin 2.6.5 is not compatible anymore with the latest Jenkins (maybe because the removed prototype.js ?).

      The sample Free style task contains 4 elements:
      1) Choice Parameter: TARGET with values:

      Item1
      Item2
      Item3

      2)  Active Choices Reactive Parameter: VARIANT, Radio Buttons, Referenced parameters=TARGET; groovy script:

       

      dynRefParam = "a1:selected a2"
      if( TARGET.equals( "Item2" ) ) 
          {
              dynRefParam = "a2:selected"
          }
      return dynRefParam.tokenize()
      

       

      3) Active Choices Reactive Parameter: MACHINES, Check Boxes, Referenced parameters: TARGET,VARIANT; groovy script:

       

      dynRefParam = "unavailable_machines"
      if ( VARIANT.equals( "a1" ) )
      {
          dynRefParam = "server1 server2 server4 server5"
      }
      if ( TARGET.equals( "Item2" ))
      {
          if ( VARIANT.equals( "a2" ) )
          {
              dynRefParam = "server1:selected"
          }
      } else if ( TARGET.equals( "Item1" ))
      {
          dynRefParam = "server2:selected server3:selected"
      }
      return dynRefParam.tokenize()
      

       

      4) Active Choices Reactive Parameter: DOCKER_BASE_IMAGE, Radio Boxes, Referenced parameters: MACHINES; groovy script:

       

      dynRefParam ="buster:selected bullseye"
      if ( MACHINES.contains( "server1" ) || MACHINES.contains( "server2" ) || MACHINES.contains( "server3" ))
      {
          dynRefParam ="buster bullseye:selected"
      }
      return dynRefParam.tokenize()
      

       

       

      The issue is when "Item2" is selected, then the 4) active-choice elements returns as selected "buster" instead of "bullseye", this because, when first called the wrong server list is returned from 3), because 3) is called with "a1" as parameter instead of "a2" as should be after the 2) gets executed.

      If Item2 is selected then from the MACHINES, server1 is de-selected then selected again, than the DOCKER_BASE_IMAGE selects correctly the  bullseye.

      Here is the full config.xml saved from the docker image:

       

      <?xml version='1.1' encoding='UTF-8'?>
      <project>
        <actions/>
        <description></description>
        <keepDependencies>false</keepDependencies>
        <properties>
          <hudson.model.ParametersDefinitionProperty>
            <parameterDefinitions>
              <hudson.model.ChoiceParameterDefinition>
                <name>TARGET</name>
                <choices class="java.util.Arrays$ArrayList">
                  <a class="string-array">
                    <string>Item1</string>
                    <string>Item2</string>
                    <string>Item3</string>
                  </a>
                </choices>
              </hudson.model.ChoiceParameterDefinition>
              <org.biouno.unochoice.CascadeChoiceParameter plugin="uno-choice@2.7.2">
                <name>VARIANT</name>
                <randomName>choice-parameter-538043095727729</randomName>
                <visibleItemCount>1</visibleItemCount>
                <script class="org.biouno.unochoice.model.GroovyScript">
                  <secureScript plugin="script-security@1273.v66c1964f0dfd">
                    <script>dynRefParam = &quot;a1:selected a2&quot;
      if( TARGET.equals( &quot;Item2&quot; ) )
              {
                      dynRefParam = &quot;a2:selected&quot;
              }
      return dynRefParam.tokenize()</script>
                    <sandbox>true</sandbox>
                  </secureScript>
                  <secureFallbackScript plugin="script-security@1273.v66c1964f0dfd">
                    <script>return [&quot;Script error&quot;]</script>
                    <sandbox>true</sandbox>
                  </secureFallbackScript>
                </script>
                <projectName>test</projectName>
                <projectFullName>test</projectFullName>
                <parameters class="linked-hash-map"/>
                <referencedParameters>TARGET</referencedParameters>
                <choiceType>PT_RADIO</choiceType>
                <filterable>false</filterable>
                <filterLength>1</filterLength>
              </org.biouno.unochoice.CascadeChoiceParameter>
              <org.biouno.unochoice.CascadeChoiceParameter plugin="uno-choice@2.7.2">
                <name>MACHINES</name>
                <randomName>choice-parameter-538043138290364</randomName>
                <visibleItemCount>1</visibleItemCount>
                <script class="org.biouno.unochoice.model.GroovyScript">
                  <secureScript plugin="script-security@1273.v66c1964f0dfd">
                    <script>dynRefParam = &quot;unavailable_machines&quot;
      if ( VARIANT.equals( &quot;a1&quot; ) )
      {
              dynRefParam = &quot;server1 server2 server4 server5&quot;
      }
      if ( TARGET.equals( &quot;Item2&quot; ))
      {
              if ( VARIANT.equals( &quot;a2&quot; ) )
              {
                      dynRefParam = &quot;server1:selected&quot;
              }
      } else if ( TARGET.equals( &quot;Item1&quot; ))
      {
              dynRefParam = &quot;server2:selected server3:selected&quot;
      }
      return dynRefParam.tokenize()</script>
                    <sandbox>true</sandbox>
                  </secureScript>
                  <secureFallbackScript plugin="script-security@1273.v66c1964f0dfd">
                    <script>return [&quot;Script error&quot;]</script>
                    <sandbox>true</sandbox>
                  </secureFallbackScript>
                </script>
                <projectName>test</projectName>
                <projectFullName>test</projectFullName>
                <parameters class="linked-hash-map"/>
                <referencedParameters>TARGET,VARIANT</referencedParameters>
                <choiceType>PT_CHECKBOX</choiceType>
                <filterable>false</filterable>
                <filterLength>1</filterLength>
              </org.biouno.unochoice.CascadeChoiceParameter>
              <org.biouno.unochoice.CascadeChoiceParameter plugin="uno-choice@2.7.2">
                <name>DOCKER_BASE_IMAGE</name>
                <randomName>choice-parameter-538043144523822</randomName>
                <visibleItemCount>1</visibleItemCount>
                <script class="org.biouno.unochoice.model.GroovyScript">
                  <secureScript plugin="script-security@1273.v66c1964f0dfd">
                    <script>dynRefParam =&quot;buster:selected bullseye&quot;
      if ( MACHINES.contains( &quot;server1&quot; ) || MACHINES.contains( &quot;server2&quot; ) || MACHINES.contains( &quot;server3&quot; ))
      {
              dynRefParam =&quot;buster bullseye:selected&quot;
      }
      return dynRefParam.tokenize()</script>
                    <sandbox>true</sandbox>
                  </secureScript>
                  <secureFallbackScript plugin="script-security@1273.v66c1964f0dfd">
                    <script>return [&quot;Script error&quot;]</script>
                    <sandbox>true</sandbox>
                  </secureFallbackScript>
                </script>
                <projectName>test</projectName>
                <projectFullName>test</projectFullName>
                <parameters class="linked-hash-map"/>
                <referencedParameters>MACHINES</referencedParameters>
                <choiceType>PT_RADIO</choiceType>
                <filterable>false</filterable>
                <filterLength>1</filterLength>
              </org.biouno.unochoice.CascadeChoiceParameter>
            </parameterDefinitions>
          </hudson.model.ParametersDefinitionProperty>
        </properties>
        <scm class="hudson.scm.NullSCM"/>
        <canRoam>true</canRoam>
        <disabled>false</disabled>
        <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
        <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
        <triggers/>
        <concurrentBuild>false</concurrentBuild>
        <builders/>
        <publishers/>
        <buildWrappers/>
      </project>
      

      Here is the "Console" log output from Firefox:

      Cascading changes from parameter TARGET... 2 UnoChoice.js:1:6332
      Values retrieved from Referenced Parameters: TARGET=Item2 UnoChoice.js:1:8457
      Values retrieved from Referenced Parameters: TARGET=Item2__LESEP__VARIANT=a1 UnoChoice.js:1:8457
      Calling Java server code to update HTML elements... 2 UnoChoice.js:1:8599
      Values returned from server: a2:selected,a2:selected UnoChoice.js:1:8738
      Updating MACHINES from VARIANT UnoChoice.js:1:12066
      Values retrieved from Referenced Parameters: TARGET=Item2__LESEP__VARIANT=a2 UnoChoice.js:1:8457
      Values returned from server: server1,server2,server4,server5,server1,server2,server4,server5 UnoChoice.js:1:8738
      Updating DOCKER_BASE_IMAGE from MACHINES UnoChoice.js:1:12066
      Values retrieved from Referenced Parameters: MACHINES= UnoChoice.js:1:8457
      Calling Java server code to update HTML elements... 2 UnoChoice.js:1:8599
      Values returned from server: buster:selected,bullseye,buster:selected,bullseye UnoChoice.js:1:8738
      Avoiding infinite loop due to recursion! UnoChoice.js:1:12169
      Values returned from server: server1:selected,server1:selected UnoChoice.js:1:8738
      Avoiding infinite loop due to recursion! UnoChoice.js:1:12169

      In fact this was originally reported in JENKINS-71724, but then the null issue was fixed, this originally reported issue remained.

       

            kinow Bruno P. Kinoshita
            szjozsef Jozsef
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: