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

Implement a pre-parameter Groovy script for totally dynamic parameters

      I would like to build totally dynamic parameters by reading an XML file (see attachment).

      My idea is that there could be a pre-parameter Groovy script, which can build parameters for the Active Choices plugin. It would have to call the plugin's API to do that, but other than that everything would be free-form.

      The idea is also, that when configuring the job, the Active Choices parameters would be shown as if they were created manually - that means that the name, the description etc. would be pre-filled, as it was configured by the Groovy script.

      It would make sense if the parameters can't be edited, but they can be moved around.

          [JENKINS-28617] Implement a pre-parameter Groovy script for totally dynamic parameters

          Please, help me understand this correctly. Are you trying to build parameters for a Jenkins job dynamically from the xml configuring them manually in a Jenkins job UI?
          In other words, will the pre-parameter Groovy script write the config.xml for the job and correctly configure active choice parameters? Kind like a DSL for active choices?

          If that's not what you mean and simply want to create Active-Choice option values from the XML file, then this is easy. You just need to write a groovy script to parse the XML and return a list of the XML elements that you want to display in your UI. The same XML file can be used to provide different option values and Active Choice parameters can help you display these values in different ways on the build UI, check boxes drop down lists etc.

          Ioannis Moutsatsos added a comment - Please, help me understand this correctly. Are you trying to build parameters for a Jenkins job dynamically from the xml configuring them manually in a Jenkins job UI? In other words, will the pre-parameter Groovy script write the config.xml for the job and correctly configure active choice parameters? Kind like a DSL for active choices? If that's not what you mean and simply want to create Active-Choice option values from the XML file, then this is easy. You just need to write a groovy script to parse the XML and return a list of the XML elements that you want to display in your UI. The same XML file can be used to provide different option values and Active Choice parameters can help you display these values in different ways on the build UI, check boxes drop down lists etc.

          cristalp added a comment -

          Well, the use case is this: The user chooses a stage (development, integration etc.) and according to that stage, the parameters are read from the XML and the form is created. I don't know if this can be done already with the Active-Choice plugin, but I couldn't get it to work that way.

          cristalp added a comment - Well, the use case is this: The user chooses a stage (development, integration etc.) and according to that stage, the parameters are read from the XML and the form is created. I don't know if this can be done already with the Active-Choice plugin, but I couldn't get it to work that way.

          I would recommend that you play with the AC Reactive Reference parameter. This parameter type allows you to create dynamic and new UI elements based on the values of the referenced parameter(s). So you would have an Active Choice parameter (let's say A) where the user selects the development stage, and then you would have one or more AC Reactive References (let's say B,C) that reference A. Depending on the value of A the reactive references B,C could render (using custom HTML elements) the custom UI controls for the value of A. See this wiki page for an example: https://wiki.jenkins-ci.org/display/JENKINS/Reactive+Reference+Dynamic+Parameter+Controls

          Ioannis Moutsatsos added a comment - I would recommend that you play with the AC Reactive Reference parameter. This parameter type allows you to create dynamic and new UI elements based on the values of the referenced parameter(s). So you would have an Active Choice parameter (let's say A) where the user selects the development stage, and then you would have one or more AC Reactive References (let's say B,C) that reference A. Depending on the value of A the reactive references B,C could render (using custom HTML elements) the custom UI controls for the value of A. See this wiki page for an example: https://wiki.jenkins-ci.org/display/JENKINS/Reactive+Reference+Dynamic+Parameter+Controls

          cristalp added a comment -

          OK, thanks for the suggestion. I'll look into it (might take a week or two) and then get back to you.

          cristalp added a comment - OK, thanks for the suggestion. I'll look into it (might take a week or two) and then get back to you.

          cristalp added a comment -

          I finally got around to use the AC Reactive Reference parameter - what a cool feature!

          I can do (almost) everything I need with it, so I'm going to close the issue.

          The only thing that would be great is to be able to run a Groovy script beforehand, because now I'm reading the same XML three times, because I need the data in three different Reactive Reference parameters. But that's just a minor niggle.

          I still have some questions about the layout, but I'll ask these on the mailing list.

          cristalp added a comment - I finally got around to use the AC Reactive Reference parameter - what a cool feature! I can do (almost) everything I need with it, so I'm going to close the issue. The only thing that would be great is to be able to run a Groovy script beforehand, because now I'm reading the same XML three times, because I need the data in three different Reactive Reference parameters. But that's just a minor niggle. I still have some questions about the layout, but I'll ask these on the mailing list.

          Hi @cristalp!

          Thanks for updating the issue, and for closing it off.

          Feel free to send any suggestions, issues, questions and comments to the mailing list. I'm currently on a development cycle for BioUno and Jenkins, working on the image-gallery-plugin, but will eventually come back to active-choices-plugin and will try to fix as many issues as possible.

          Bruno

          Bruno P. Kinoshita added a comment - Hi @cristalp! Thanks for updating the issue, and for closing it off. Feel free to send any suggestions, issues, questions and comments to the mailing list. I'm currently on a development cycle for BioUno and Jenkins, working on the image-gallery-plugin, but will eventually come back to active-choices-plugin and will try to fix as many issues as possible. Bruno

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

              Created:
              Updated:
              Resolved: