Skip to content

Commit

Permalink
Merge pull request #823 from jglick/agent-name
Browse files Browse the repository at this point in the history
Decouple `InboundAgentRule.Options.name` from `-jnlpUrl`
  • Loading branch information
jglick authored Aug 30, 2024
2 parents 352b51a + f8531f4 commit a3529e2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/jvnet/hudson/test/InboundAgentRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -53,6 +54,7 @@
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
import org.junit.rules.ExternalResource;
Expand Down Expand Up @@ -330,10 +332,11 @@ public void start(AgentArguments agentArguments, Options options) throws Excepti
cmd.add("Xrunjdwp:transport=dt_socket,server=y,address=" + (JenkinsRule.SLAVE_DEBUG_PORT + agentArguments.numberOfNodes - 1));
}
cmd.addAll(List.of("-jar", agentArguments.agentJar.getAbsolutePath()));
if (agentArguments.agentJnlpUrl.endsWith("computer/" + options.getName() + "/slave-agent.jnlp") && remotingVersion(agentArguments.agentJar).isNewerThanOrEqualTo(new VersionNumber("3186.vc3b_7249b_87eb_"))) {
cmd.addAll(List.of("-url", agentArguments.agentJnlpUrl.replaceAll("computer/" + options.getName() + "/slave-agent.jnlp$", "")));
var m = Pattern.compile("(.+)computer/([^/]+)/slave-agent[.]jnlp").matcher(agentArguments.agentJnlpUrl);
if (m.matches() && remotingVersion(agentArguments.agentJar).isNewerThanOrEqualTo(new VersionNumber("3186.vc3b_7249b_87eb_"))) {
cmd.addAll(List.of("-url", m.group(1)));
cmd.addAll(List.of("-secret", agentArguments.secret));
cmd.addAll(List.of("-name", options.getName()));
cmd.addAll(List.of("-name", URI.create(m.group(2)).getPath()));
if (options.isWebSocket()) {
cmd.add("-webSocket");
}
Expand Down

0 comments on commit a3529e2

Please sign in to comment.