Class AbstractScriptableParameter

All Implemented Interfaces:
ExtensionPoint, Describable<ParameterDefinition>, Serializable, ScriptableParameter<Map<Object,Object>>, UnoChoiceParameter
Direct Known Subclasses:
AbstractCascadableParameter, ChoiceParameter

public abstract class AbstractScriptableParameter extends AbstractUnoChoiceParameter implements ScriptableParameter<Map<Object,Object>>
Base class for parameters with scripts.
Since:
0.20
Author:
Bruno P. Kinoshita
See Also:
  • Field Details

    • SEPARATOR

      protected static final String SEPARATOR
      Used to split values that come from the UI via Ajax POST's
      See Also:
    • EQUALS

      protected static final String EQUALS
      Used to split values when scripts return values like A=2, B=3.
      See Also:
    • JENKINS_PROJECT_VARIABLE_NAME

      protected static final String JENKINS_PROJECT_VARIABLE_NAME
      Constant used to add the project in the environment variables map.
      See Also:
    • JENKINS_BUILD_VARIABLE_NAME

      protected static final String JENKINS_BUILD_VARIABLE_NAME
      Constant used to add the build in the environment variables map.
      See Also:
    • JENKINS_PARAMETER_VARIABLE_NAME

      protected static final String JENKINS_PARAMETER_VARIABLE_NAME
      Constant used to add the parameter name in the environment variables map.
      See Also:
    • script

      protected final Script script
      Script used to render the parameter.
  • Constructor Details

    • AbstractScriptableParameter

      @Deprecated protected AbstractScriptableParameter(String name, String description, Script script)
      Deprecated.
      see JENKINS-32149
      Inherited constructor.
      Parameters:
      name - name
      description - description
      script - script used to generate the list of parameter values
    • AbstractScriptableParameter

      protected AbstractScriptableParameter(String name, String description, String randomName, Script script)
      Inherited constructor.
      Parameters:
      name - name
      description - description
      randomName - parameter random generated name (uuid)
      script - script used to generate the list of parameter values
  • Method Details

    • detectProject

      protected AbstractItem detectProject()
    • getScript

      public Script getScript()
      Gets the script.
      Returns:
      the script
    • getParameters

      public Map<Object,Object> getParameters()
      Gets the current parameters, be it before or after other referenced parameters triggered an update. Populates parameters common to all evaluations, such as jenkinsProject, which is the current Jenkins project.
      Returns:
      the current parameters with pre-populated defaults
    • getChoices

      public Map<Object,Object> getChoices()
    • getChoices

      public Map<Object,Object> getChoices(Map<Object,Object> parameters)
      Description copied from interface: ScriptableParameter
      Evaluates a script and returns its result as a Map. List values are automatically handled and converted to Maps too.
      Specified by:
      getChoices in interface ScriptableParameter<Map<Object,Object>>
      Parameters:
      parameters - parameters
      Returns:
      script result as Map
    • getChoicesAsString

      public String getChoicesAsString()
    • getChoicesAsString

      public String getChoicesAsString(Map<Object,Object> parameters)
    • getDefaultParameterValue

      public ParameterValue getDefaultParameterValue()
      Overrides:
      getDefaultParameterValue in class ParameterDefinition
    • getVisibleItemCount

      public int getVisibleItemCount()
      Get the number of visible items in the select.
      Returns:
      the number of choices or, if it is higher than the default, then it returns the default maximum value