diff --git a/pom.xml b/pom.xml
index 5e58bf88c..a5d3e065d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,7 +57,7 @@
org.jenkins-ci.plugins
github-api
- 1.58
+ 1.59
org.jenkins-ci.plugins
diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbGitHub.java b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbGitHub.java
index 9ea86b7fd..5382377ce 100644
--- a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbGitHub.java
+++ b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbGitHub.java
@@ -6,6 +6,7 @@
import org.kohsuke.github.GHOrganization;
import org.kohsuke.github.GHUser;
import org.kohsuke.github.GitHub;
+import org.kohsuke.github.GitHubBuilder;
/**
* @author janinko
@@ -19,7 +20,11 @@ private void connect() throws IOException{
String serverAPIUrl = GhprbTrigger.getDscp().getServerAPIUrl();
if(accessToken != null && !accessToken.isEmpty()) {
try {
- gh = GitHub.connectUsingOAuth(serverAPIUrl, accessToken);
+ gh = new GitHubBuilder()
+ .withEndpoint(serverAPIUrl)
+ .withOAuthToken(accessToken)
+ .withConnector(new HttpConnectorWithJenkinsProxy())
+ .build();
} catch(IOException e) {
logger.log(Level.SEVERE, "Can''t connect to {0} using oauth", serverAPIUrl);
throw e;
@@ -28,7 +33,10 @@ private void connect() throws IOException{
if (serverAPIUrl.contains("api/v3")) {
gh = GitHub.connectToEnterprise(serverAPIUrl, GhprbTrigger.getDscp().getUsername(), GhprbTrigger.getDscp().getPassword());
} else {
- gh = GitHub.connectUsingPassword(GhprbTrigger.getDscp().getUsername(), GhprbTrigger.getDscp().getPassword());
+ gh = new GitHubBuilder()
+ .withPassword(GhprbTrigger.getDscp().getUsername(), GhprbTrigger.getDscp().getPassword())
+ .withConnector(new HttpConnectorWithJenkinsProxy())
+ .build();
}
}
}
diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/HttpConnectorWithJenkinsProxy.java b/src/main/java/org/jenkinsci/plugins/ghprb/HttpConnectorWithJenkinsProxy.java
new file mode 100644
index 000000000..bbfb3fe95
--- /dev/null
+++ b/src/main/java/org/jenkinsci/plugins/ghprb/HttpConnectorWithJenkinsProxy.java
@@ -0,0 +1,14 @@
+package org.jenkinsci.plugins.ghprb;
+
+import hudson.ProxyConfiguration;
+import org.kohsuke.github.HttpConnector;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public class HttpConnectorWithJenkinsProxy implements HttpConnector{
+ public HttpURLConnection connect(URL url) throws IOException {
+ return (HttpURLConnection)ProxyConfiguration.open(url);
+ }
+}