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

Render an AC Reactive reference as a functional Jenkins File Parameter

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • active-choices-plugin
    • None
    • active-choices v1.3

      An AC Reactive Reference can be rendered as formatted HTML. This allows you to render a parameter as a variety of HTML control types. In addition, if the HTML rendered is of the format <input type="InputType" name="value" > the value returned from the parameter is usable in the build.
      This works successfully with at least the following InputTypes that I've tested:

      • checkbox
      • range
      • month
      • datetime-local
      • color
        That's pretty cool, but I now want to render a Jenkins File Parameter.

      The groovy script for this is very simple:

      html='''
      <input name="value" type="file" jsonaware="true">
      '''
      return html

      This is rendered and functions correctly with one exception. The selected file never gets uploaded to the server as a normal Jenkins File Parameter would. Making this work would be a great way to render a dynamic File Parameter in the UI.

          [JENKINS-32566] Render an AC Reactive reference as a functional Jenkins File Parameter

          The File Chooser is rendered from the AC-Reactive Ref code and it will allow you to open a file chooser and select a file. However, the selected file is not uploaded to the server as a normal Jenkins File Parameter would.

          Ioannis Moutsatsos added a comment - The File Chooser is rendered from the AC-Reactive Ref code and it will allow you to open a file chooser and select a file. However, the selected file is not uploaded to the server as a normal Jenkins File Parameter would.

          Code changed in jenkins
          User: Bruno P. Kinoshita
          Path:
          src/main/java/org/biouno/unochoice/AbstractUnoChoiceParameter.java
          http://jenkins-ci.org/commit/active-choices-plugin/10b9b24d468dfd36f62d88ded3ad7d816d16a75b
          Log:
          [FIXED JENKINS-32566] Return a FileParameterDefinition when JSON request for a HTML rendered parameter contains a file key

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Bruno P. Kinoshita Path: src/main/java/org/biouno/unochoice/AbstractUnoChoiceParameter.java http://jenkins-ci.org/commit/active-choices-plugin/10b9b24d468dfd36f62d88ded3ad7d816d16a75b Log: [FIXED JENKINS-32566] Return a FileParameterDefinition when JSON request for a HTML rendered parameter contains a file key

          The groovy script needs to have the name equals file, not value in this case.

          html='''
          <input name="file" type="file" jsonaware="true">
          '''
          return html
          

          Furthermore, the plug-in was always, by default, returning a parameter value of type String. Now when you pass a key file in the JSON (it is all done automagically in Jenkins), the plug-in first checks for that and once it finds it, it returns a file definition parameter instead.

          Hopefully the old behaviour was not affected, but just to play safe, I won't release it immediately.

          Posting about new release to mailing list, which will require some testing in our testbed server with the snapshot, which will contain the fix for this issue. In case you find that it works there, just let me know and I will cut a new release. Might be a good if we add some notes to the Wiki about how to use file upload controllers with active choice as well.

          Bruno P. Kinoshita added a comment - The groovy script needs to have the name equals file, not value in this case. html=''' <input name= "file" type= "file" jsonaware= " true " > ''' return html Furthermore, the plug-in was always, by default, returning a parameter value of type String. Now when you pass a key file in the JSON (it is all done automagically in Jenkins), the plug-in first checks for that and once it finds it, it returns a file definition parameter instead. Hopefully the old behaviour was not affected, but just to play safe, I won't release it immediately. Posting about new release to mailing list, which will require some testing in our testbed server with the snapshot, which will contain the fix for this issue. In case you find that it works there, just let me know and I will cut a new release. Might be a good if we add some notes to the Wiki about how to use file upload controllers with active choice as well.

            kinow Bruno P. Kinoshita
            ioannis Ioannis Moutsatsos
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: