Package org.jenkinsci.lib.configprovider
Class ConfigProvider
- java.lang.Object
-
- hudson.model.Descriptor<Config>
-
- org.jenkinsci.lib.configprovider.ConfigProvider
-
- All Implemented Interfaces:
ExtensionPoint
,Saveable
,OnMaster
- Direct Known Subclasses:
AbstractConfigProviderImpl
public abstract class ConfigProvider extends Descriptor<Config> implements ExtensionPoint
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 ofConfigProvider
.- 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
Constructors Constructor Description ConfigProvider()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ExtensionList<ConfigProvider>
all()
All registeredConfigProvider
s.abstract void
clearOldDataStorage()
boolean
configExists(String configId)
Deprecated.Collection<Config>
getAllConfigs()
Deprecated.UseConfigFiles.getConfigsInContext(ItemGroup, Class)
instead.static ConfigProvider
getByIdOrNull(String providerId)
Lookup aConfigProvider
by its id.Config
getConfigById(String configId)
Deprecated.abstract ContentType
getContentType()
The content type of the configs this provider manages.abstract String
getProviderId()
An ID uniquely identifying this provider, the id of eachConfig
must start with this ID separated by a '.'!List<String>
getSensitiveContentForMasking(Config configFile, Run<?,?> build)
Obtain a list of sensitive Strings to mask for the given provider and build.Config
newConfig()
Deprecated.Config
newConfig(String id)
Returns a newConfig
object.Config
newConfig(String id, String name, String comment, String content)
void
remove(String configId)
Deprecated.Use @{code GlobalConfigFiles.get().remove(String)} instead.void
save(Config config)
Deprecated.UseGlobalConfigFiles.get().save(Config)
instead.String
supplyContent(Config configFile, Run<?,?> build, FilePath workDir, TaskListener listener, List<String> tempFiles)
Provide the given content file.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.-
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
-
-
-
-
Method Detail
-
all
public static ExtensionList<ConfigProvider> all()
All registeredConfigProvider
s.
-
getByIdOrNull
@CheckForNull public static ConfigProvider getByIdOrNull(@Nullable String providerId)
Lookup aConfigProvider
by its id.- Parameters:
providerId
- id of the desiredConfigProvider
- Returns:
- the
ConfigProvider
ornull
if not found
-
getContentType
public abstract ContentType 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
public abstract String 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 public Config 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
@NonNull public Config newConfig(@NonNull String id)
Returns a newConfig
object.- Parameters:
id
- desired id- Returns:
- the created configuration
- Since:
- 2.10.0
-
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:
GlobalConfigFiles
-
getAllConfigs
@Deprecated public Collection<Config> getAllConfigs()
Deprecated.UseConfigFiles.getConfigsInContext(ItemGroup, Class)
instead.This will only return configurations on top/global scope
-
getConfigById
@Deprecated public Config getConfigById(String configId)
Deprecated.
-
configExists
@Deprecated public boolean configExists(String configId)
Deprecated.
-
remove
@Deprecated public void remove(String configId)
Deprecated.Use @{code GlobalConfigFiles.get().remove(String)} instead.
-
save
@Deprecated public void save(Config config)
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 IOException
Provide 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(Config, Run)
-
getSensitiveContentForMasking
@NonNull public List<String> getSensitiveContentForMasking(Config configFile, Run<?,?> build)
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.
-
-