Skip to content
Browse files
[FIXED JENKINS-10634] JDK downloader now uses Jenkins proxy settings
  • Loading branch information
Andrew Bradley authored and kohsuke committed Sep 18, 2011
1 parent beb1666 commit fa00cd25296af0b1958be8d55a787a585b18e3e0
Showing with 23 additions and 0 deletions.
  1. +3 −0 changelog.html
  2. +20 −0 core/src/main/java/hudson/tools/
@@ -55,6 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
JDK auto-installation does not respect proxy settings
(<a href="">issue 10634</a>)
<li class=bug>
Tools download does not respect proxy settings
(<a href="">issue 5271</a>)
@@ -23,6 +23,9 @@

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.DefaultCredentialsProvider;
import com.gargoylesoftware.htmlunit.ProxyConfig;
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
@@ -31,6 +34,7 @@
import hudson.AbortException;
import hudson.Extension;
import hudson.FilePath;
import hudson.ProxyConfiguration;
import hudson.Launcher;
import hudson.Launcher.ProcStarter;
import hudson.Util;
@@ -45,6 +49,7 @@
import hudson.util.Secret;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.apache.commons.httpclient.auth.CredentialsProvider;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.HttpResponse;
@@ -344,6 +349,21 @@ public URL locate(TaskListener log, Platform platform, CPU cpu) throws IOExcepti
URL src = new URL(primary.filepath);

WebClient wc = new WebClient();
// honor jenkins proxy settings in WebClient
Jenkins h = Jenkins.getInstance();
ProxyConfiguration jpc = h!=null ? h.proxy : null;
if(jpc != null) {
ProxyConfig pc = new ProxyConfig();
if(jpc.getUserName() != null) {
DefaultCredentialsProvider cp = new DefaultCredentialsProvider();
cp.addCredentials(jpc.getUserName(), jpc.getPassword(),, jpc.port, null);

Page page = wc.getPage(src);

1 comment on commit fa00cd2


This comment has been minimized.

Copy link

@tom-canova tom-canova commented on fa00cd2 Sep 19, 2011

For me, it is still not respecting the proxy configuration
I'm using Jenkins ver. 1.432-SNAPSHOT (private-09/19/2011 18:09 GMT-jenkins)

We don't use a username/password for our proxy. If jsp.getUsername() returned "", that would cause a problem for us.

Also - installation of plugins was not respecting the proxy for us.

Here's the console output:
Started by user anonymous Installing JDK jdk-6u26-oth-JPR Downloading JDK from
ERROR: Failed to parse POMs GET failed at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse( at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection( at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse( at com.gargoylesoftware.htmlunit.WebClient.getPage( at com.gargoylesoftware.htmlunit.WebClient.getPage( at at at at at at hudson.model.JDK.forNode( at hudson.model.AbstractBuild.getEnvironment( at hudson.maven.AbstractMavenBuild.getEnvironment( at hudson.maven.MavenModuleSetBuild.getEnvironment( at hudson.maven.MavenModuleSetBuild$RunnerImpl.doRun( at hudson.model.AbstractBuild$ at at at hudson.model.ResourceController.execute( at Caused by: Connection timed out: connect at Method) at Source) at Source) at Source) at Source) at Source) at Source) at Source) at Source) at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket( at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket( at at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry( at org.apache.commons.httpclient.HttpMethodDirector.executeMethod( at org.apache.commons.httpclient.HttpClient.executeMethod( at org.apache.commons.httpclient.HttpClient.executeMethod( at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse( ... 19 more Finished: FAILURE

and here's the error from trying to install a plugin

Active Directory plugin
Failure - Server returned HTTP response code: 502 for URL:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at$ Source)
at Method)
at Source)
at Source)
at hudson.model.UpdateCenter$
at hudson.model.UpdateCenter$DownloadJob._run(
at hudson.model.UpdateCenter$InstallationJob._run(
at hudson.model.UpdateCenter$
at java.util.concurrent.Executors$ Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)
Caused by: Server returned HTTP response code: 502 for URL:
at Source)
at Source)
at Source)
at Source)
at hudson.model.UpdateCenter$
... 9 more

Please sign in to comment.