diff --git a/src/main/java/io/jenkins/plugins/projectenv/WithProjectEnvStepExecution.java b/src/main/java/io/jenkins/plugins/projectenv/WithProjectEnvStepExecution.java index 9ac1320..ab88047 100644 --- a/src/main/java/io/jenkins/plugins/projectenv/WithProjectEnvStepExecution.java +++ b/src/main/java/io/jenkins/plugins/projectenv/WithProjectEnvStepExecution.java @@ -108,7 +108,12 @@ private void execute() throws Exception { private String resolveProjectEnvCliExecutableFromPath(AgentInfo agentInfo) throws Exception { String[] commands = getExecutablePathResolveCommand(agentInfo); - return StringUtils.trimToNull(ProcHelper.executeAndGetStdOut(getContext(), commands)); + String stdOut = StringUtils.trimToNull(ProcHelper.executeAndGetStdOut(getContext(), commands)); + if (stdOut == null) { + return null; + } + + return stdOut.split(agentInfo.getLineSeparator())[0]; } private String[] getExecutablePathResolveCommand(AgentInfo agentInfo) { diff --git a/src/main/java/io/jenkins/plugins/projectenv/agent/AgentInfo.java b/src/main/java/io/jenkins/plugins/projectenv/agent/AgentInfo.java index c2b1a99..fcdf561 100644 --- a/src/main/java/io/jenkins/plugins/projectenv/agent/AgentInfo.java +++ b/src/main/java/io/jenkins/plugins/projectenv/agent/AgentInfo.java @@ -9,5 +9,6 @@ public interface AgentInfo extends Serializable { OperatingSystem getOperatingSystem(); + String getLineSeparator(); } diff --git a/src/main/java/io/jenkins/plugins/projectenv/agent/AgentInfoCallable.java b/src/main/java/io/jenkins/plugins/projectenv/agent/AgentInfoCallable.java index 19c21a1..233afb8 100644 --- a/src/main/java/io/jenkins/plugins/projectenv/agent/AgentInfoCallable.java +++ b/src/main/java/io/jenkins/plugins/projectenv/agent/AgentInfoCallable.java @@ -9,7 +9,9 @@ public class AgentInfoCallable extends MasterToSlaveCallable