Skip to content

Commit

Permalink
[JENKINS-40225] replace backslashes for windows shell
Browse files Browse the repository at this point in the history
  • Loading branch information
blatinville committed Dec 21, 2016
1 parent e174ce7 commit 362f895
Showing 1 changed file with 13 additions and 3 deletions.
Expand Up @@ -89,7 +89,7 @@ public String getScript() {

FilePath shf = c.getScriptFile(ws);

String s = script;
String s = script, scriptPath;
final Jenkins jenkins = Jenkins.getInstance();
if (!s.startsWith("#!") && jenkins != null) {
String defaultShell = jenkins.getInjector().getInstance(Shell.DescriptorImpl.class).getShellOrDefault(ws.getChannel());
Expand All @@ -98,6 +98,11 @@ public String getScript() {
shf.write(s, "UTF-8");
shf.chmod(0755);

scriptPath = shf.getRemote();
if (ws.act(new WindowsCheck())) { // JENKINS-40255
scriptPath= scriptPath.replace("\\", "/"); // cygwin sh understands mixed path (ie : "c:/jenkins/workspace/script.sh" )
}

envVars.put(cookieVariable, "please-do-not-kill-me");
// The temporary variable is to ensure JENKINS_SERVER_COOKIE=durable-… does not appear even in argv[], lest it be confused with the environment.
String cmd;
Expand All @@ -106,7 +111,7 @@ public String getScript() {
c.pidFile(ws),
cookieValue,
cookieVariable,
shf,
scriptPath,
c.getOutputFile(ws),
c.getLogFile(ws),
c.getResultFile(ws));
Expand All @@ -115,7 +120,7 @@ public String getScript() {
c.pidFile(ws),
cookieValue,
cookieVariable,
shf,
scriptPath,
c.getLogFile(ws),
c.getResultFile(ws));
}
Expand Down Expand Up @@ -220,5 +225,10 @@ private static final class DarwinCheck extends MasterToSlaveCallable<Boolean,Run
return Platform.isDarwin();
}
}
private static final class WindowsCheck extends MasterToSlaveCallable<Boolean,RuntimeException> {
@Override public Boolean call() throws RuntimeException {
return Platform.current() == Platform.WINDOWS ;
}
}

}

0 comments on commit 362f895

Please sign in to comment.