Class JsonParameterReferenceDefinition.DescriptorImpl

java.lang.Object
hudson.model.Descriptor<ParameterDefinition>
hudson.model.ParameterDefinition.ParameterDescriptor
com.github.cyanbaz.jenkins.plugins.jsonparameter.JsonParameterReferenceDefinition.DescriptorImpl
All Implemented Interfaces:
Saveable, Loadable, OnMaster
Enclosing class:
JsonParameterReferenceDefinition

@Extension @Symbol("jsonParamRef") public static class JsonParameterReferenceDefinition.DescriptorImpl extends ParameterDefinition.ParameterDescriptor
Descriptor for JsonParameterReferenceDefinition.

Registers the parameter type under the symbol jsonParamRef and provides the Stapler endpoint doLoadOptions, which Jenkins uses to fetch the filtered options at runtime when the referenced parameter changes.

  • Constructor Details

    • DescriptorImpl

      public DescriptorImpl()
  • Method Details

    • getDisplayName

      @NonNull public String getDisplayName()
      Returns the display name shown in the Jenkins UI.
      Overrides:
      getDisplayName in class ParameterDefinition.ParameterDescriptor
      Returns:
      A string representing the UI name
    • doLoadOptions

      @POST public org.kohsuke.stapler.HttpResponse doLoadOptions(@AncestorInPath Job<?,?> job, @QueryParameter String paramName, @QueryParameter String refValue)
      AJAX endpoint used by the build form to populate the dropdown of a JsonParameterReferenceDefinition.

      This method is invoked via descriptorByName/.../loadOptions whenever the referenced parameter changes. It resolves the query by substituting the placeholder (e.g. ${USERS}) with the current reference value, evaluates the JSON source, and returns a JSON array of option objects:

       [
         {"name":"Alice","value":"alice","selected":false},
         {"name":"Bob","value":"bob","selected":true}
       ]
       

      Errors are returned as an array with a single object containing an explanatory name and empty value.

      Parameters:
      job - the job context (injected by Stapler)
      paramName - the name of the parameter definition to resolve
      refValue - the current value of the referenced parameter (may be empty)
      Returns:
      JSON array of dropdown options or an error placeholder