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

Active Choice Reactive Reference parameter value rendered as File Selector not cascaded

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      When an Active Choice reactive reference is rendered as a Jenkins File Chooser, the name of the selected file is not cascaded to other active choices that reference it.

        Attachments

          Activity

          ioannis Ioannis Moutsatsos created issue -
          kinow Bruno P. Kinoshita made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          ioannis Ioannis Moutsatsos added a comment -

          After investigating a bit more, the issue is as follows:

          When the AC-RefParam is rendered as:

          <input name="file" type="file" jsonaware="true">
          
          • we render a file button that we can use to choose a file.
          • the name of the file is NOT cascaded
          • the file is uploaded.

          When the AC-RefParam is rendered as:

          <input name="value" type="file" jsonaware="true">
          
          • we render a file button that we can use to choose a file
          • the name of the file is cascaded
          • the file however, is NOT uploaded

          This is expected as we need to render a parameter with name="value". It's just not useful for us to propagate the name of the selected file.

          Show
          ioannis Ioannis Moutsatsos added a comment - After investigating a bit more, the issue is as follows: When the AC-RefParam is rendered as: <input name= "file" type= "file" jsonaware= " true " > we render a file button that we can use to choose a file. the name of the file is NOT cascaded the file is uploaded. When the AC-RefParam is rendered as: <input name= "value" type= "file" jsonaware= " true " > we render a file button that we can use to choose a file the name of the file is cascaded the file however, is NOT uploaded This is expected as we need to render a parameter with name="value". It's just not useful for us to propagate the name of the selected file.
          ioannis Ioannis Moutsatsos made changes -
          Attachment config[1].xml [ 38753 ]
          kinow Bruno P. Kinoshita made changes -
          Hide
          kinow Bruno P. Kinoshita added a comment -

          Hi Ioannis,

          Thanks for attaching the config.xml file. That is extremely helpful.

          Here are some screen shots.

           

          I am not sure if I can reproduce it or not... I suspect it is working in my environment? Could be because I am running within Eclipse, locally, with no security policies, HTTP server, etc.

           

          But at least when I choose a file from my desktop, the input fields are updated, and the values are both submitted to Jenkins.

          Show
          kinow Bruno P. Kinoshita added a comment - Hi Ioannis, Thanks for attaching the config.xml file. That is extremely helpful. Here are some screen shots.   I am not sure if I can reproduce it or not... I suspect it is working in my environment? Could be because I am running within Eclipse, locally, with no security policies, HTTP server, etc.   But at least when I choose a file from my desktop, the input fields are updated, and the values are both submitted to Jenkins.
          Hide
          ioannis Ioannis Moutsatsos added a comment -

          Maybe the example is confusing. But you have actually reproduced the issue as described in my comment.
          Your screenshot shows that the Krita.desktop file, attached using the AC_RENDERED file button was NOT uploaded. And this is exactly my issue.
          I want an Active Choice rendered 'Choose File' button that both cascades its value AND uploads the file

          Show
          ioannis Ioannis Moutsatsos added a comment - Maybe the example is confusing. But you have actually reproduced the issue as described in my comment. Your screenshot shows that the Krita.desktop file, attached using the AC_RENDERED file button was NOT uploaded. And this is exactly my issue. I want an Active Choice rendered 'Choose File' button that both cascades its value AND uploads the file
          ioannis Ioannis Moutsatsos made changes -
          Priority Minor [ 4 ] Major [ 3 ]
          Hide
          ioannis Ioannis Moutsatsos added a comment -

          Changed the severity, as this is directly affecting the expected behavior of the AC control

          Show
          ioannis Ioannis Moutsatsos added a comment - Changed the severity, as this is directly affecting the expected behavior of the AC control
          kinow Bruno P. Kinoshita made changes -
          Attachment screenshot-1.png [ 46970 ]
          Hide
          kinow Bruno P. Kinoshita added a comment - - edited

          Ok, I think I finally understood the issue and what's going on. What we have when we use Jenkins' File parameter is a FileParameterValue.

          The Jelly file used to render is very simple and it seems like the part we are missing here is that the input field's name must be "file", not "value".

          If you want to cascade to other parameters, I think you will have to find some JavaScript that reacts to the event when the user chooses the file, then copies the file name in another input name="value".

          So in summary, the only thing I changed from your example to get it working was: <input name="file" type="file" jsonAware="true" />

          To match Jenkins' jelly file.

          Could you check if that works for you Ioannis Moutsatsos, please? Here's a screen shot (also checked in the disk, and both files were uploaded, but no file name in the latter).

          Show
          kinow Bruno P. Kinoshita added a comment - - edited Ok, I think I finally understood the issue and what's going on. What we have when we use Jenkins' File parameter is a FileParameterValue . The Jelly file used to render is very simple and it seems like the part we are missing here is that the input field's name must be "file", not "value". If you want to cascade to other parameters, I think you will have to find some JavaScript that reacts to the event when the user chooses the file, then copies the file name in another input name="value". So in summary, the only thing I changed from your example to get it working was: <input name="file" type="file" jsonAware="true" /> To match Jenkins' jelly file. Could you check if that works for you Ioannis Moutsatsos , please? Here's a screen shot (also checked in the disk, and both files were uploaded, but no file name in the latter).
          Hide
          ioannis Ioannis Moutsatsos added a comment -

          Thanks for looking into this Bruno! So you have clearly confirmed my previous investigation: https://issues.jenkins-ci.org/browse/JENKINS-38893?focusedCommentId=305784&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-305784 Excellent!

           

          I will investigate the workaround  you suggested, but I think this is the first case where we can't reproduce a functional Jenkins UI control whose value can be cascaded in the typical AC way. I will try to document on wiki after I find a workaround for it.

          Thank you-have a great Sunday afternoon in NZ!

          Show
          ioannis Ioannis Moutsatsos added a comment - Thanks for looking into this Bruno! So you have clearly confirmed my previous investigation: https://issues.jenkins-ci.org/browse/JENKINS-38893?focusedCommentId=305784&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-305784  Excellent!   I will investigate the workaround  you suggested, but I think this is the first case where we can't reproduce a functional Jenkins UI control whose value can be cascaded in the typical AC way. I will try to document on wiki after I find a workaround for it. Thank you-have a great Sunday afternoon in NZ!
          Hide
          dozinbatty Sunil Batra added a comment -

          The issue mentioned Ioannis Moutsatsos is there, but I could add another finding, when we use the same active choice in pipeline job, the file is not uploaded either you specify 
          <input name="file" type="file" jsonaware="true">
          OR
          <input name="value" type="file" jsonaware="true">
          In Pipeline type of job, you can get the name of the file, but do not have a space where the file could be located.

          Show
          dozinbatty Sunil Batra added a comment - The issue mentioned Ioannis Moutsatsos is there, but I could add another finding, when we use the same active choice in pipeline job, the file is not uploaded either you specify  <input name="file" type="file" jsonaware="true"> OR <input name="value" type="file" jsonaware="true"> In Pipeline type of job, you can get the name of the file, but do not have a space where the file could be located.
          whatsdevops Angelo Loria made changes -
          Comment [ [~dozinbatty] did you find a resolution for your issue? I'm facing the same thing in a pipeline:

           
          {code:java}
                                [
                                  $class: 'DynamicReferenceParameter',
                                  choiceType: 'ET_FORMATTED_HTML',
                                  description: '',
                                  name: fileParam,
                                  omitValueField: false,
                                  referencedParameters: actionParam,
                                  script: [
                                     $class: 'GroovyScript',
                                     fallbackScript: [
                                        classpath: [],
                                        sandbox: false,
                                        script: ''
                                     ],
                                     script: [
                                        classpath: [],
                                        sandbox: false,
                                        script: 'if(Action == \'ExecuteScript\') { return \'\'\'<input name="value" type="file" jsonaware="true">\'\'\'}'
                                     ]
                                  ]
                               ]





          {code}
            ]
          Hide
          whatsdevops Angelo Loria added a comment - - edited

          Sunil Batra did you ever figure this out? I'm facing the same issue.

                                [
                                  $class: 'DynamicReferenceParameter',
                                  choiceType: 'ET_FORMATTED_HTML',
                                  description: '',
                                  name: 'File',
                                  omitValueField: true,
                                  referencedParameters: actionParam,
                                  script: [
                                     $class: 'GroovyScript',
                                     fallbackScript: [
                                        classpath: [],
                                        sandbox: false,
                                        script: ''
                                     ],
                                     script: [
                                        classpath: [],
                                        sandbox: false,
                                        script: 'if(Action == \'ExecuteScript\') { return \'\'\'<input name="value" type="file" jsonaware="true">\'\'\'}'
                                     ]
                                  ]
                               ],
          

          This code results in the env.File parameter getting the value 'file0', but there is no file. Changing the input name to "file" also does not result in a file being uploaded.

          EDIT: Figured it out. File was getting uploaded, needed to use input name "file" and I borrowed some of this code to get that file to the current workspace- https://github.com/janvrany/jenkinsci-unstashParam-library

          Show
          whatsdevops Angelo Loria added a comment - - edited Sunil Batra did you ever figure this out? I'm facing the same issue. [ $class: 'DynamicReferenceParameter' , choiceType: 'ET_FORMATTED_HTML' , description: '', name: 'File' , omitValueField: true , referencedParameters: actionParam, script: [ $class: 'GroovyScript' , fallbackScript: [ classpath: [], sandbox: false , script: '' ], script: [ classpath: [], sandbox: false , script: ' if (Action == \' ExecuteScript\ ') { return \' \ '\' <input name= "value" type= "file" jsonaware= " true " >\ '\' \ '}' ] ] ], This code results in the env.File parameter getting the value 'file0', but there is no file. Changing the input name to "file" also does not result in a file being uploaded. EDIT: Figured it out. File was getting uploaded, needed to use input name "file" and I borrowed some of this code to get that file to the current workspace- https://github.com/janvrany/jenkinsci-unstashParam-library

            People

            Assignee:
            kinow Bruno P. Kinoshita
            Reporter:
            ioannis Ioannis Moutsatsos
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: