Class PluginHelper
- java.lang.Object
-
- io.jenkins.plugins.artifactrepo.helper.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 Summary
Constructors Constructor Description PluginHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HttpResponse
get(String url, org.apache.http.impl.client.HttpClientBuilder builder)
Convenience method ofget(String, HttpClientBuilder, HttpClientContext)
with a default client context.static HttpResponse
get(String url, org.apache.http.impl.client.HttpClientBuilder builder, org.apache.http.client.protocol.HttpClientContext context)
A generic implementation to do GET requests with automatic resource clean up.static org.apache.http.impl.client.HttpClientBuilder
getBuilder(String repoCredId, ArtifactRepoParamProxy proxy, boolean ignoreSSL)
Returns an opinionated and preconfigured HttpClient builder object.static com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials
getCredentials(String credId)
Get the Jenkins credentials object of type StandardUsernamePasswordCredentials identified by the provided ID string.static org.apache.http.HttpHost
getHttpHostFromUrl(String urlString)
Takes a URL string and creates aHttpHost
object of it.
-
-
-
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 callbuilder
- The builder object used to create theHttpClient
.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.
-
get
public static HttpResponse get(@Nonnull String url, @Nonnull org.apache.http.impl.client.HttpClientBuilder builder)
Convenience method ofget(String, HttpClientBuilder, HttpClientContext)
with a default client context.
-
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.
-
getHttpHostFromUrl
public static org.apache.http.HttpHost getHttpHostFromUrl(@Nonnull String urlString) throws MalformedURLException
Takes a URL string and creates aHttpHost
object of it.- Throws:
MalformedURLException
-
-