Class PluginHelper


  • public class PluginHelper
    extends Object
    A simple utility class to help create the HTTP connection from the plugin to the target repository instances.
    • Constructor Detail

      • PluginHelper

        public PluginHelper()
    • Method Detail

      • get

        public static HttpResponse get​(@Nonnull
                                       String url,
                                       @Nonnull
                                       org.apache.http.impl.client.HttpClientBuilder builder,
                                       @Nonnull
                                       org.apache.http.client.protocol.HttpClientContext context)
        A generic implementation to do GET requests with automatic resource clean up.
        Parameters:
        url - The URL to call
        builder - The builder object used to create the HttpClient.
        context - A possible context object to add to the request. Can be used to perform pre-emptive authentication (required by Nexus).
        Returns:
        An instance of HttpResponse with both return code and response payload.
      • getBuilder

        public static org.apache.http.impl.client.HttpClientBuilder getBuilder​(@Nonnull
                                                                               String repoCredId,
                                                                               @Nonnull
                                                                               ArtifactRepoParamProxy proxy,
                                                                               boolean ignoreSSL)
        Returns an opinionated and preconfigured HttpClient builder object.
        Parameters:
        repoCredId - The ID of the credentials object that should get used to authenticate at the target repository instance.
        proxy - A proxy object with all the proxy information in it.
        ignoreSSL - Whether or not to ignore invalid SSL certificates (e. g. self-signed).
        Returns:
        An HttpClientBuilder object with some pre-defined configurations.
      • getCredentials

        public static com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials getCredentials​(@Nonnull
                                                                                                                  String credId)
        Get the Jenkins credentials object of type StandardUsernamePasswordCredentials identified by the provided ID string.