8000 [JENKINS-33623] Fix incorrect proxy handling by schulzh · Pull Request #48 · jenkinsci/github-branch-source-plugin · GitHub
[go: up one dir, main page]

Skip to content

[JENKINS-33623] Fix incorrect proxy handling #48

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

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
import hudson.security.ACL;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.util.List;
9E5A import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
Expand Down Expand Up @@ -101,6 +103,7 @@ public class Connector {
}

gb.withRateLimitHandler(CUSTOMIZED);

OkHttpClient client = new OkHttpClient().setProxy(getProxy(defaultIfBlank(apiUrl, GITHUB_URL)));

gb.withConnector(new OkHttpConnector(new OkUrlFactory(client)));
Expand Down Expand Up @@ -146,10 +149,17 @@ private static List<DomainRequirement> githubDomainRequirements(String apiUri) {
private static Proxy getProxy(String apiUrl) {
Jenkins jenkins = GitHubWebHook.getJenkinsInstance();

String host;
try {
host = new URL(apiUrl).getHost();
} catch (MalformedURLException e) {
throw new RuntimeException("Could not extract host from api url", e);
}

if (jenkins.proxy == null) {
return Proxy.NO_PROXY;
} else {
return jenkins.proxy.createProxy(apiUrl);
return jenkins.proxy.createProxy(host);
}
}

Expand Down
0