Package org.jenkinsci.lib.configprovider
Class ConfigProvider
- All Implemented Interfaces:
ExtensionPoint
,Saveable
,OnMaster
- Direct Known Subclasses:
AbstractConfigProviderImpl
A ConfigProvider represents a configuration file (such as Maven's settings.xml) where the user can choose its actual content among several concrete contents that are
pre-configured.
ConfigProvider
is an extension point, and should be implemented and instantiated by each kind of configuration. This abstraction doesn't define where the configuration is placed, or
how/when it's used — those semantics should be introduced by a specific instance of ConfigProvider
.
- Author:
- Dominik Bartholdi (imod)
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Fields inherited from class hudson.model.Descriptor
clazz
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<ConfigProvider>
all()
All registeredConfigProvider
s.abstract void
boolean
configExists
(String configId) Deprecated.Deprecated.UseConfigFiles.getConfigsInContext(ItemGroup, Class)
instead.static ConfigProvider
getByIdOrNull
(String providerId) Lookup aConfigProvider
by its id.getConfigById
(String configId) Deprecated.abstract ContentType
The content type of the configs this provider manages.abstract String
An ID uniquely identifying this provider, the id of eachConfig
must start with this ID separated by a '.'!getSensitiveContentForMasking
(Config configFile, Run<?, ?> build) Obtain a list of sensitive Strings to mask for the given provider and build.Deprecated.Returns a newConfig
object.void
Deprecated.Use @{code GlobalConfigFiles.get().remove(String)} instead.void
Deprecated.UseGlobalConfigFiles.get().save(Config)
instead.supplyContent
(Config configFile, Run<?, ?> build, FilePath workDir, TaskListener listener, List<String> tempFiles) Provide the given content file.boolean
Tells whether this provider is able to handle configuration files stored on folder level too, or if it only supports global configuration files.Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getDisplayName, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
Constructor Details
-
ConfigProvider
public ConfigProvider()
-
-
Method Details
-
all
All registeredConfigProvider
s. -
getByIdOrNull
Lookup aConfigProvider
by its id.- Parameters:
providerId
- id of the desiredConfigProvider
- Returns:
- the
ConfigProvider
ornull
if not found
-
getContentType
The content type of the configs this provider manages. e.g. can be used to display the content in the UI (editor).- Returns:
- the type.
null
if no specific formatting should be supported.
-
getProviderId
An ID uniquely identifying this provider, the id of eachConfig
must start with this ID separated by a '.'!- Returns:
- the unique id for this provider.
-
newConfig
Deprecated.Returns a newConfig
object with a unique id, starting with the id of this provider - separated by '.'. e.g. "MyCustomProvider.123456". This object is also used initialize the user interface.- Returns:
- the new config object, ready for editing.
-
newConfig
Returns a newConfig
object.- Parameters:
id
- desired id- Returns:
- the created configuration
- Since:
- 2.10.0
-
newConfig
-
clearOldDataStorage
public abstract void clearOldDataStorage() -
supportsFolder
public boolean supportsFolder()Tells whether this provider is able to handle configuration files stored on folder level too, or if it only supports global configuration files. This flag will tell the web UI whether a file can be created on a folder. Defaults totrue
, overwrite if your configfiles are not support on folders.- Returns:
true
if the provider supports configfiles stored on folder levels too.- See Also:
-
getAllConfigs
Deprecated.UseConfigFiles.getConfigsInContext(ItemGroup, Class)
instead.This will only return configurations on top/global scope -
getConfigById
Deprecated. -
configExists
Deprecated. -
remove
Deprecated.Use @{code GlobalConfigFiles.get().remove(String)} instead. -
save
Deprecated.UseGlobalConfigFiles.get().save(Config)
instead. -
supplyContent
@CheckForNull public String supplyContent(@NonNull Config configFile, Run<?, ?> build, FilePath workDir, TaskListener listener, @NonNull List<String> tempFiles) throws IOExceptionProvide the given content file. Implementation Note:If this is overridden in a sub class and credentials are injected into the content - then the implementation must also overridegetSensitiveContentForMasking(Config, Run)
to avoid accidental disclosure.- Parameters:
configFile
- the file content to be providedworkDir
- target workspace directorylistener
- the listenertempFiles
- temp files created by this method, these files will be deleted by the caller- Returns:
- file content
- Throws:
IOException
- in case an exception occurs when providing the content or other needed files- Since:
- 2.16
- See Also:
-
getSensitiveContentForMasking
Obtain a list of sensitive Strings to mask for the given provider and build. For example if aUsernamePasswordCredentials
is being injected into a file then the password (and possibly the username) from the resolved credential would need to be masked and should be returned here.- Parameters:
configFile
- the file content to provide sensitive strings for.build
- the build for which the configFile applies.- Returns:
- List of Strings that need to be masked in the console.
-
ConfigFiles.getByIdOrNull(hudson.model.ItemGroup, java.lang.String)
instead.