Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Query Jenkins through channel to support nodes
According to
https://issues.jenkins-ci.org/browse/JENKINS-20223?focusedCommentId=188427&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-188427
it is not possible to obtain the Jenkins instance from a node, so we go
through the remoting channel instead.
  • Loading branch information
Oli Dagenais committed Feb 23, 2016
1 parent 64262a7 commit 4771a8a
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/main/java/hudson/plugins/tfs/model/Server.java
Expand Up @@ -74,7 +74,8 @@ else if (username != null && password != null) {
this.webProxySettings = webProxySettings;
}
else {
final ProxyConfiguration proxyConfiguration = determineProxyConfiguration();
final VirtualChannel channel = launcher != null ? launcher.getChannel() : null;
final ProxyConfiguration proxyConfiguration = determineProxyConfiguration(channel);
this.webProxySettings = new WebProxySettings(proxyConfiguration);
}
this.tpc = new TFSTeamProjectCollection(uri, credentials);
Expand All @@ -89,10 +90,30 @@ else if (username != null && password != null) {
this(null, null, url, null, null);
}

static ProxyConfiguration determineProxyConfiguration() {
static ProxyConfiguration determineProxyConfiguration(final VirtualChannel channel) {
final Jenkins jenkins = Jenkins.getInstance();
final ProxyConfiguration proxyConfiguration;
proxyConfiguration = jenkins.proxy;
if (jenkins == null) {
if (channel != null) {
try {
proxyConfiguration = channel.call(new Callable<ProxyConfiguration, Throwable>() {
public ProxyConfiguration call() throws Throwable {
final Jenkins jenkins = Jenkins.getInstance();
final ProxyConfiguration result = jenkins != null ? jenkins.proxy : null;
return result;
}
});
} catch (final Throwable throwable) {
throw new Error(throwable);
}
}
else {
proxyConfiguration = null;
}
}
else {
proxyConfiguration = jenkins.proxy;
}
return proxyConfiguration;
}

Expand Down

0 comments on commit 4771a8a

Please sign in to comment.