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

Allow for Multiple Inputs to Be Passed to Pipelines with ET_FORMATTED_HTML Type

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • active-choices-plugin
    • None
    • Jenkins Version 2.467
      Ubuntu 20.04
      OpenJDK Java 17
      Active Choices Plugin 2.8.1

      I have a use case where I would like to create a DynamicReferenceParameter that based on a suite chosen in a dropdown creates inputs for all of the known parameters in that suite and then passes it down to the pipeline.  I believe this could be converted into a JSON string of some sort and passed in that way.  Right now, ET_FORMATTED_HTML only passes for one input element.  

      I have this form working, but setting the inputs doesn't do anything as expected.

       [
                              $class: 'DynamicReferenceParameter',
                              description: 'All parameters shown are needed for the chosen playbook.',
                              name: 'Parameters',
                              referencedParameters:'playbook',
                              choiceType: "ET_FORMATTED_HTML",
                              script: [
                                      $class: 'GroovyScript',
                                      script: [
                                              sandbox: false,
                                              script: """
      import org.yaml.snakeyaml.Yaml
      def file = new File("/var/lib/jenkins/userContent/${jenkins.env.JOB_BASE_NAME}-manifest.yaml")
      def input = new Yaml().load(file.text)
      def selectedPlaybook = playbook
      def inputs = ""
      input[selectedPlaybook]["variables"].each{ param ->
          inputs += \"\"\"
              <div name="parameter" class="jenkins-form-item">
                  <div class="jenkins-form-label">
                      <label class="jenkins-label" for=\$param>\${param}:</label>
                  </div>
                  <div class="jenkins-form-control">
                      <input name=\$param id=\$param class="jenkins-input">
                  </div>
              </div>
          \"\"\"
      }

      def html = \"\"\"
              <div class="jenkins-form-item tr">
              <div class="jenkins-form-label"></div>
                  <div class="jenkins-form-control">
                      <div id="parameter-container">
                          \${inputs}
                      </div>
              </div>
              </div>
              \"\"\"
      return html
                                  """
                                      ]
                              ]
                      ]

            kinow Bruno P. Kinoshita
            assertpequalspspace Kurt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: