Class 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 of ConfigProvider.

    Author:
    Dominik Bartholdi (imod)
    • Constructor Detail

      • ConfigProvider

        public ConfigProvider()
    • Method Detail

      • 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 each Config must start with this ID separated by a '.'!
        Returns:
        the unique id for this provider.
      • newConfig

        @Deprecated
        public Config newConfig()
        Deprecated.
        Returns a new Config 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 new Config 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 to true, overwrite if your configfiles are not support on folders.
        Returns:
        true if the provider supports configfiles stored on folder levels too.
        See Also:
        GlobalConfigFiles
      • remove

        @Deprecated
        public void remove​(String configId)
        Deprecated.
        Use @{code GlobalConfigFiles.get().remove(String)} instead.
      • save

        @Deprecated
        public void save​(Config config)
        Deprecated.
        Use GlobalConfigFiles.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 override getSensitiveContentForMasking(Config, Run) to avoid accidental disclosure.
        Parameters:
        configFile - the file content to be provided
        workDir - target workspace directory
        listener - the listener
        tempFiles - 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 a UsernamePasswordCredentials 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.