-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Minor
-
Component/s: active-choices-plugin
-
None
-
Environment: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
              """
                ]
            ]
        ]