Class ConfigFileSource
java.lang.Object
hudson.model.AbstractDescribableImpl<JsonSource>
com.github.cyanbaz.jenkins.plugins.jsonparameter.JsonSource
com.github.cyanbaz.jenkins.plugins.jsonparameter.ConfigFileSource
- All Implemented Interfaces:
ExtensionPoint
,Describable<JsonSource>
,Serializable
A
JsonSource
implementation that loads JSON content from a Jenkins Config File,
either globally scoped or folder-scoped.
When folder-scoped, the parameter is only available to jobs located within the specified folder or its subfolders.
This class supports validation to prevent unauthorized access to configuration files outside the designated folder path.
- Author:
- Caner Yanbaz
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Descriptor forConfigFileSource
, shown as an option in the dropdown selector.Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
ConstructorsConstructorDescriptionConfigFileSource
(boolean folderScoped, String folderPath, String configId) Constructs a newConfigFileSource
instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
loadJson()
Loads the JSON content from the configured Jenkins config file.Methods inherited from class com.github.cyanbaz.jenkins.plugins.jsonparameter.JsonSource
loadOptions
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
Constructor Details
-
ConfigFileSource
@DataBoundConstructor public ConfigFileSource(boolean folderScoped, String folderPath, String configId) Constructs a newConfigFileSource
instance.- Parameters:
folderScoped
- whether the config file is folder-scopedfolderPath
- the full Jenkins path of the folder (only relevant if folderScoped is true)configId
- the ID of the config file as defined in the Config File Provider plugin
-
-
Method Details
-
isFolderScoped
public boolean isFolderScoped() -
getFolderPath
-
getConfigId
-
loadJson
Loads the JSON content from the configured Jenkins config file.If
folderScoped
is true, the method resolves the folder using the configured path, ensures the current job is inside that folder, and retrieves the corresponding config. IffolderScoped
is false, it attempts to resolve the config globally.- Specified by:
loadJson
in classJsonSource
- Returns:
- the raw JSON content as a string
- Throws:
IllegalArgumentException
- if the config file is not found or not accessibleIllegalStateException
- if folder-scoped access fails (e.g. folder mismatch or missing permission)
-