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

Active Choices Reactive Reference Parameter of type Formatted Hidden HTML is not hidden when defined in pipeline

      I am using Pipeline script from SCM and define everything within including Parameters:

      properties([
        parameters([
          ...,
          [
            $class: 'DynamicReferenceParameter',
            choiceType: 'ET_FORMATTED_HIDDEN_HTML',
            name: 'Test',
            omitValueField: true,
            script: [
                $class: 'GroovyScript',
                script: [
                    classpath: [],
                    sandbox: true,
                    script: """
                        return '''whatever
                        '''
                    """
                ]
            ]
          ]
        ])
      ])
      
      pipeline {
      ...
      }

      If I run the pipeline the parameter is shown but then I save it in the config page it no longer shows up. I tried to look at config.xml in the jobs folder to see any difference but nothing.

          [JENKINS-75454] Active Choices Reactive Reference Parameter of type Formatted Hidden HTML is not hidden when defined in pipeline

          Pinned comments

          Pinned by David

          David added a comment -

          One more thing. I use it to show and hide other parameters depending on the selection of others:

          [
                  $class: 'DynamicReferenceParameter',
                  choiceType: 'ET_FORMATTED_HIDDEN_HTML',
                  name: 'Test_update',
                  referencedParameters: 'serviceupdate',
                  omitValueField: true,
                  script: [
                      $class: 'GroovyScript',
                      script: [
                          $class: 'SecureGroovyScript',
                          sandbox: false,
                          script: '''services = serviceupdate.split(',').collect{it as String}
          if (services.contains('ABC')) {
            return """
            <img src="force/failed/load/image" style="display: none;" onerror="document.querySelectorAll('input[value=&quot;target&quot;]')[0].closest('.jenkins-form-item').style.display='none'">
          """
          } else {
            return """
            <img src="force/failed/load/image" style="display: none;" onerror="document.querySelectorAll('input[value=&quot;target&quot;]')[0].closest('.jenkins-form-item').style.display=''">
          """
          }'''
                      ]
                  ]
              ] 

          this also doesn't work until I save it in the config page.

          David added a comment - One more thing. I use it to show and hide other parameters depending on the selection of others: [         $class: 'DynamicReferenceParameter' ,         choiceType: 'ET_FORMATTED_HIDDEN_HTML' ,         name: 'Test_update' ,         referencedParameters: 'serviceupdate' ,         omitValueField: true ,         script: [             $class: 'GroovyScript' ,             script: [                 $class: 'SecureGroovyScript' ,                 sandbox: false ,                 script: '''services = serviceupdate.split(' ,').collect{it as String } if (services.contains( 'ABC' )) {   return """   <img src= "force/failed/load/image" style= "display: none;" onerror= "document.querySelectorAll( 'input[value=&quot;target&quot;]' )[0].closest( '.jenkins-form-item' ).style.display= 'none' " > """ } else {   return """   <img src= "force/failed/load/image" style= "display: none;" onerror= "document.querySelectorAll( 'input[value=&quot;target&quot;]' )[0].closest( '.jenkins-form-item' ).style.display=''" > """ }'''             ]         ]     ] this also doesn't work until I save it in the config page.

          All comments

          Pinned by David

          David added a comment -

          One more thing. I use it to show and hide other parameters depending on the selection of others:

          [
                  $class: 'DynamicReferenceParameter',
                  choiceType: 'ET_FORMATTED_HIDDEN_HTML',
                  name: 'Test_update',
                  referencedParameters: 'serviceupdate',
                  omitValueField: true,
                  script: [
                      $class: 'GroovyScript',
                      script: [
                          $class: 'SecureGroovyScript',
                          sandbox: false,
                          script: '''services = serviceupdate.split(',').collect{it as String}
          if (services.contains('ABC')) {
            return """
            <img src="force/failed/load/image" style="display: none;" onerror="document.querySelectorAll('input[value=&quot;target&quot;]')[0].closest('.jenkins-form-item').style.display='none'">
          """
          } else {
            return """
            <img src="force/failed/load/image" style="display: none;" onerror="document.querySelectorAll('input[value=&quot;target&quot;]')[0].closest('.jenkins-form-item').style.display=''">
          """
          }'''
                      ]
                  ]
              ] 

          this also doesn't work until I save it in the config page.

          David added a comment - One more thing. I use it to show and hide other parameters depending on the selection of others: [         $class: 'DynamicReferenceParameter' ,         choiceType: 'ET_FORMATTED_HIDDEN_HTML' ,         name: 'Test_update' ,         referencedParameters: 'serviceupdate' ,         omitValueField: true ,         script: [             $class: 'GroovyScript' ,             script: [                 $class: 'SecureGroovyScript' ,                 sandbox: false ,                 script: '''services = serviceupdate.split(' ,').collect{it as String } if (services.contains( 'ABC' )) {   return """   <img src= "force/failed/load/image" style= "display: none;" onerror= "document.querySelectorAll( 'input[value=&quot;target&quot;]' )[0].closest( '.jenkins-form-item' ).style.display= 'none' " > """ } else {   return """   <img src= "force/failed/load/image" style= "display: none;" onerror= "document.querySelectorAll( 'input[value=&quot;target&quot;]' )[0].closest( '.jenkins-form-item' ).style.display=''" > """ }'''             ]         ]     ] this also doesn't work until I save it in the config page.

          Hi martensd , could you provide a complete example to reproduce it, please? I work on the plug-in on spare time (after dinner before going to bed, early morning waiting for a meeting to start, etc.). So I have short 15-60 mins and try to prioritize the issues that fit into that time window.

          If you can create a complete example, and share the config.xml, then it'd be easier for me to reproduce the bug locally, and then quickly look at the code + debugger and see if I can spot what's wrong.

          Thank you

          Bruno P. Kinoshita added a comment - Hi martensd , could you provide a complete example to reproduce it, please? I work on the plug-in on spare time (after dinner before going to bed, early morning waiting for a meeting to start, etc.). So I have short 15-60 mins and try to prioritize the issues that fit into that time window. If you can create a complete example, and share the config.xml, then it'd be easier for me to reproduce the bug locally, and then quickly look at the code + debugger and see if I can spot what's wrong. Thank you

            kinow Bruno P. Kinoshita
            martensd David
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: