Class JsonParameterDefinition
java.lang.Object
hudson.model.ParameterDefinition
com.github.cyanbaz.jenkins.plugins.jsonparameter.JsonParameterDefinition
- All Implemented Interfaces:
ExtensionPoint
,Describable<ParameterDefinition>
,Serializable
Represents a custom Jenkins parameter definition that extracts values from a JSON source
(either from a local config file or a remote URL) using a JSONPath expression.
This class integrates with Jenkins' build parameters system and provides dynamic dropdown population via the UI or CLI.
- Author:
- Caner Yanbaz
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Descriptor for this parameter type, defines how it is represented in Jenkins UI.Nested classes/interfaces inherited from class hudson.model.ParameterDefinition
ParameterDefinition.ParameterDescriptor
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Fields inherited from class hudson.model.ParameterDefinition
LIST
-
Constructor Summary
ConstructorsConstructorDescriptionJsonParameterDefinition
(String name, String defaultValue, JsonSource source, String query) Data-bound constructor called by Jenkins when binding UI input. -
Method Summary
Modifier and TypeMethodDescriptioncreateValue
(CLICommand command, String value) Creates a parameter value from a CLI command.createValue
(org.kohsuke.stapler.StaplerRequest2 req) Creates a parameter value from a standard web form submission.createValue
(org.kohsuke.stapler.StaplerRequest2 req, net.sf.json.JSONObject jo) Creates a parameter value from the submitted JSON object in the web form.Returns the default parameter value as configured.Returns a localized message used when no options are available in the dropdown.getQuery()
Methods inherited from class hudson.model.ParameterDefinition
all, copyWithDefaultValue, createValue, createValue, equals, getDescription, getDescriptor, getFormattedDescription, getName, getType, hashCode, isValid, setDescription
-
Constructor Details
-
JsonParameterDefinition
@DataBoundConstructor public JsonParameterDefinition(String name, String defaultValue, JsonSource source, String query) Data-bound constructor called by Jenkins when binding UI input.- Parameters:
name
- The name of the parameterdefaultValue
- The default value used when none is providedsource
- The JSON source definitionquery
- JSONPath query used to extract dropdown values
-
-
Method Details
-
getDefaultValue
-
getSource
-
getQuery
-
getPlaceholderMessage
Returns a localized message used when no options are available in the dropdown.- Returns:
- A localized empty option message
-
getDefaultParameterValue
Returns the default parameter value as configured.- Overrides:
getDefaultParameterValue
in classParameterDefinition
- Returns:
- StringParameterValue with default value
-
createValue
public ParameterValue createValue(org.kohsuke.stapler.StaplerRequest2 req, net.sf.json.JSONObject jo) Creates a parameter value from the submitted JSON object in the web form.- Overrides:
createValue
in classParameterDefinition
- Parameters:
req
- The stapler requestjo
- The submitted JSON object- Returns:
- A new StringParameterValue instance
-
createValue
Creates a parameter value from a standard web form submission.- Overrides:
createValue
in classParameterDefinition
- Parameters:
req
- The stapler request- Returns:
- A new StringParameterValue instance
-
createValue
Creates a parameter value from a CLI command.- Overrides:
createValue
in classParameterDefinition
- Parameters:
command
- The CLI commandvalue
- The CLI argument provided- Returns:
- A new StringParameterValue instance
-