Search in sources :

Example 1 with GitHubBuilder

use of org.kohsuke.github.GitHubBuilder in project blueocean-plugin by jenkinsci.

the class GitHubFactory method connect.

/**
 * Connect to github with the correct limit handlers
 * @param accessToken to authorize
 * @param endpointUri endpoint to connect to
 * @return GitHub
 * @throws IOException if GitHub could not be constructed
 */
public static GitHub connect(String accessToken, String endpointUri) throws IOException {
    URL apiUrl = new URL(endpointUri);
    ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
    Proxy proxy = proxyConfig == null ? Proxy.NO_PROXY : proxyConfig.createProxy(apiUrl.getHost());
    return new GitHubBuilder().withOAuthToken(accessToken).withRateLimitHandler(RateLimitHandlerImpl.INSTANCE).withAbuseLimitHandler(AbuseLimitHandlerImpl.INSTANCE).withProxy(proxy).withEndpoint(endpointUri).build();
}
Also used : Proxy(java.net.Proxy) ProxyConfiguration(hudson.ProxyConfiguration) GitHubBuilder(org.kohsuke.github.GitHubBuilder) URL(java.net.URL)

Aggregations

ProxyConfiguration (hudson.ProxyConfiguration)1 Proxy (java.net.Proxy)1 URL (java.net.URL)1 GitHubBuilder (org.kohsuke.github.GitHubBuilder)1