Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED JENKINS-24592] Support HTTP proxies #49

Merged
merged 1 commit into from
Oct 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>github-api</artifactId>
<version>1.58</version>
<version>1.59</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbGitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}