diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 2208b9fb02..9e87991574 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -1925,7 +1925,7 @@ public class Functions { TcpSlaveAgentListener tal = j.tcpSlaveAgentListener; if (tal !=null) { - int p = TcpSlaveAgentListener.CLI_PORT !=null ? TcpSlaveAgentListener.CLI_PORT : tal.getPort(); + int p = tal.getAdvertisedPort(); rsp.setIntHeader("X-Hudson-CLI-Port", p); rsp.setIntHeader("X-Jenkins-CLI-Port", p); rsp.setIntHeader("X-Jenkins-CLI2-Port", p); diff --git a/core/src/main/java/hudson/TcpSlaveAgentListener.java b/core/src/main/java/hudson/TcpSlaveAgentListener.java index 22e548bcfb..86934ed7ae 100644 --- a/core/src/main/java/hudson/TcpSlaveAgentListener.java +++ b/core/src/main/java/hudson/TcpSlaveAgentListener.java @@ -94,6 +94,13 @@ public final class TcpSlaveAgentListener extends Thread { return serverSocket.socket().getLocalPort(); } + /** + * Gets the TCP port number in which we are advertising. + */ + public int getAdvertisedPort() { + return CLI_PORT != null ? CLI_PORT : getPort(); + } + @Override public void run() { try { diff --git a/core/src/main/resources/hudson/TcpSlaveAgentListener/index.jelly b/core/src/main/resources/hudson/TcpSlaveAgentListener/index.jelly index 9e65250be2..d2dc352fac 100644 --- a/core/src/main/resources/hudson/TcpSlaveAgentListener/index.jelly +++ b/core/src/main/resources/hudson/TcpSlaveAgentListener/index.jelly @@ -28,8 +28,8 @@ THE SOFTWARE. Publicize the TCP port number for JNLP slave agents so that they know where to conenct. Keep the legacy header for better backward compatibility --> - - + +