Class GitHubConfigFileProviderImpl

    • Constructor Detail

      • GitHubConfigFileProviderImpl

        public GitHubConfigFileProviderImpl()
    • Method Detail

      • fetchConfigFile

        public <T> Optional<T> fetchConfigFile​(org.kohsuke.github.GHRepository repository,
                                               String path,
                                               ConfigFile.Source source,
                                               Class<T> type)
        Description copied from interface: GitHubConfigFileProvider
        Fetches the configuration file at the given path from the main branch of the given repository, optionally (if type is not just String) deserializing it to the given type using Jackson.

        NOTE: You generally will not need this method when processing events, as configuration files can be automatically injected into event listener methods, simply by annotating a parameter with ConfigFile. This provider is mostly useful for non-event use cases (e.g. cron jobs).

        Specified by:
        fetchConfigFile in interface GitHubConfigFileProvider
        Parameters:
        repository - The GitHub code repository to retrieve the file from.
        path - The path to the file in the code repository, either absolute (if it starts with /) or relative to /.github/ (if it doesn't start with /).
        source - Which repository to extract the file from in the case of forked repositories.
        type - The type to deserialize the file to.
        Returns:
        The configuration file wrapped in an Optional, or Optional.empty() if it is missing.
        See Also:
        ConfigFile, ConfigFile.Source
      • fetchConfigFile

        public <T> Optional<T> fetchConfigFile​(org.kohsuke.github.GHRepository repository,
                                               String ref,
                                               String path,
                                               ConfigFile.Source source,
                                               Class<T> type)
        Description copied from interface: GitHubConfigFileProvider
        Fetches the configuration file at the given path from the given ref of the given repository, optionally (if type is not just String) deserializing it to the given type using Jackson.

        NOTE: You generally will not need this method when processing events, as configuration files can be automatically injected into event listener methods, simply by annotating a parameter with ConfigFile. This provider is mostly useful for non-event use cases (e.g. cron jobs).

        Specified by:
        fetchConfigFile in interface GitHubConfigFileProvider
        Parameters:
        repository - The GitHub code repository to retrieve the file from.
        ref - The git ref (branch, commit SHA, ...) to retrieve the file from.
        path - The path to the file in the code repository, either absolute (if it starts with /) or relative to /.github/ (if it doesn't start with /).
        source - Which repository to extract the file from in the case of forked repositories.
        type - The type to deserialize the file to.
        Returns:
        The configuration file wrapped in an Optional, or Optional.empty() if it is missing.
        See Also:
        ConfigFile, ConfigFile.Source
      • getFilePath

        public static String getFilePath​(String path)