Class ConfigFileSource

All Implemented Interfaces:
ExtensionPoint, Describable<JsonSource>, Serializable

public class ConfigFileSource extends JsonSource
A JsonSource implementation that loads JSON content from a Jenkins Config File.

Resolution is hierarchical: Jenkins searches the current folder and its parents, falling back to globally defined configuration files if no folder-local match is found.

This class uses the Config File Provider plugin for resolution and validation.

Author:
Caner Yanbaz
See Also:
  • Constructor Details

    • ConfigFileSource

      @DataBoundConstructor public ConfigFileSource(@NonNull String configId)
      Constructs a new ConfigFileSource instance.
      Parameters:
      configId - the ID of the config file as defined in the Config File Provider plugin
  • Method Details

    • getConfigId

      public String getConfigId()
    • loadJson

      public String loadJson()
      Loads the JSON content from the configured Jenkins config file.

      The config is resolved hierarchically in the context of the current Jenkins item: nearest folder → parent folders → global.

      Specified by:
      loadJson in class JsonSource
      Returns:
      the raw JSON content as a string
      Throws:
      IllegalArgumentException - if the config file or Jenkins item is not found
      IllegalStateException - if no Jenkins item is available in the current request context