Skip to content
Permalink
Browse files

[JENKINS-39596] - Restore assigning of hudsonUrl in hudson.remoting.E…

…ngine

It's a regression in remotirn-3.0
  • Loading branch information
oleg-nenashev committed Nov 9, 2016
1 parent ecefcc7 commit 837bfeb81e8ed360e8350711b59fb8d9f3311882
@@ -128,6 +128,7 @@ public void run() {
* This value is determined from {@link #candidateUrls} after a successful connection.
* Note that this URL <b>DOES NOT</b> have "tcpSlaveAgentListener" in it.
*/
@CheckForNull
private URL hudsonUrl;

private final String secretKey;
@@ -171,6 +172,12 @@ public void setJarCache(JarCache jarCache) {
this.jarCache = jarCache;
}

/**
* Provides Jenkins URL if available.
* @return Jenkins URL. May return {@code null} if the connection is not established or if the URL cannot be determined
* in the {@link JnlpAgentEndpointResolver}.
*/
@CheckForNull
public URL getHudsonUrl() {
return hudsonUrl;
}
@@ -334,6 +341,7 @@ private void innerRun(IOHub hub, SSLContext context, ExecutorService service) {
events.status("Could not resolve server among " + candidateUrls);
return;
}
hudsonUrl = endpoint.getServiceUrl();

events.status(String.format("Agent discovery successful%n"
+ " Agent address: %s%n"
@@ -29,6 +29,7 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URL;
import java.nio.channels.SocketChannel;
import java.security.interfaces.RSAPublicKey;
import java.util.Collections;
@@ -65,24 +66,44 @@
*/
@CheckForNull
private final Set<String> protocols;

/**
* Jenkins URL for the discovered endpoint.
* @since TODO
*/
@CheckForNull
private final URL serviceUrl;

/**
* @deprecated Use {@link #JnlpAgentEndpoint(java.lang.String, int, java.security.interfaces.RSAPublicKey, java.util.Set, java.lang.String)}
*/
@Deprecated
public JnlpAgentEndpoint(@Nonnull String host, int port, @CheckForNull RSAPublicKey publicKey,
@CheckForNull Set<String> protocols) {
this(host, port, publicKey, protocols, null);
}

/**
* Constructor for a remote {@code Jenkins} instance.
*
* @param host the hostname.
* @param port the port.
* @param publicKey the {@code InstanceIdentity.getPublic()} of the remote instance (if known).
* @param protocols The supported protocols.
* @param serviceURL URL of the service hosting the remoting endpoint.
* Use {@code null} if it is not a web service or if the URL cannot be determined
* @since TODO
*/
public JnlpAgentEndpoint(@Nonnull String host, int port, @CheckForNull RSAPublicKey publicKey,
@CheckForNull Set<String> protocols) {
@CheckForNull Set<String> protocols, @CheckForNull URL serviceURL) {
if (port <= 0 || 65536 <= port) {
throw new IllegalArgumentException("Port " + port + " is not in the range 1-65535");
}
this.host = host;
this.port = port;
this.publicKey = publicKey;
this.protocols = protocols == null ? null : Collections.unmodifiableSet(new LinkedHashSet<String>(protocols));
this.serviceUrl = serviceURL;
}

/**
@@ -95,6 +116,15 @@ public InetSocketAddress getAddress() {
return new InetSocketAddress(host, port);
}

/**
* Retrieves URL of the web service providing the remoting endpoint.
* @return Service URL if available. {@code null} otherwise.
*/
@CheckForNull
public URL getServiceUrl() {
return serviceUrl;
}

/**
* Gets the hostname.
*
@@ -232,7 +232,8 @@ public int compare(String o1, String o2) {
if (tokens[0].length() > 0) host = tokens[0];
if (tokens[1].length() > 0) port = Integer.parseInt(tokens[1]);
}
return new JnlpAgentEndpoint(host, port, identity, agentProtocolNames);

return new JnlpAgentEndpoint(host, port, identity, agentProtocolNames, selectedJenkinsURL);
} finally {
con.disconnect();
}

0 comments on commit 837bfeb

Please sign in to comment.
You can’t perform that action at this time.