Class ConfigFiles
java.lang.Object
org.jenkinsci.plugins.configfiles.ConfigFiles
Central class to access configuration files
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Config>
TgetByIdOrNull(ItemGroup itemGroup, String configId) Used to get hold on a single configuration in the given context.static <T extends Config>
TgetByIdOrNull(Item item, String configId) Used to get hold on a single configuration in the given context.static <T extends Config>
TgetByIdOrNull(Run<?, ?> build, String configId) Used to get hold on a single configuration in the given context.getConfigsInContext(ItemGroup itemGroup, Class<? extends Descriptor> descriptor) Lists all configurations of the given type which are visible in the context of the provided item group.
-
Method Details
-
getConfigsInContext
@NonNull public static List<Config> getConfigsInContext(@Nullable ItemGroup itemGroup, Class<? extends Descriptor> descriptor) Lists all configurations of the given type which are visible in the context of the provided item group. e.g. if itemGroup is of typeAbstractFolderor within anAbstractFolder, then this method will list all configurations in that folder and in all parent folders up (and including) all configurations on jenkins top level.This method is typically used to display all available options in the UI.
- Parameters:
itemGroup- the contextdescriptor- configuration type- Returns:
- a list of configuration items of the requested type, visible in the provided context.
-
getByIdOrNull
public static <T extends Config> T getByIdOrNull(@Nullable ItemGroup itemGroup, @NonNull String configId) Used to get hold on a single configuration in the given context. The configuration will be looked up for from the current context (itemGroup, e.g.AbstractFolderorJenkinsif not within a folder) until a configuration with the given id was found.- Type Parameters:
T- expected type of the returned configuration item.- Parameters:
itemGroup- context to start the lookup fromconfigId- id of the configuration to search for- Returns:
nullif no configuration was found- Throws:
IllegalArgumentException- if while walking up the tree, one of the parents is not either of typeAbstractFolder,ItemorJenkins
-
getByIdOrNull
Used to get hold on a single configuration in the given context. The configuration will be looked up for from the current context (item, e.g.AbstractFolderorJenkinsif not within a folder) until a configuration with the given id was found.- Type Parameters:
T- expected type of the returned configuration item.- Parameters:
item- context to start the lookup fromconfigId- id of the configuration to search for- Returns:
nullif no configuration was found- Throws:
IllegalArgumentException- if while walking up the tree, one of the parents is not either of typeAbstractFolder,ItemorJenkins
-
getByIdOrNull
Used to get hold on a single configuration in the given context. The configuration will be looked up for from the current context (itemGroup, e.g.AbstractFolderorJenkinsif not within a folder) until a configuration with the given id was found.Usually used to access the configuration during a run/job execution.
- Type Parameters:
T- expected type of the returned configuration item.- Parameters:
build- active to start the lookup fromconfigId- id of the configuration to search for- Returns:
nullif no configuration was found- Throws:
IllegalArgumentException- if while walking up the tree, one of the parents is not either of typeAbstractFolder,ItemorJenkins
-