Skip to content
Permalink
Browse files

[JENKINS-40225] replace backslashes for windows shell

  • Loading branch information...
blatinville committed Dec 19, 2016
1 parent e174ce7 commit 362f8959cd4c289e1614d6aeecf503863da70903
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java
@@ -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());
@@ -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;
@@ -106,7 +111,7 @@ public String getScript() {
c.pidFile(ws),
cookieValue,
cookieVariable,
shf,
scriptPath,
c.getOutputFile(ws),
c.getLogFile(ws),
c.getResultFile(ws));
@@ -115,7 +120,7 @@ public String getScript() {
c.pidFile(ws),
cookieValue,
cookieVariable,
shf,
scriptPath,
c.getLogFile(ws),
c.getResultFile(ws));
}
@@ -220,5 +225,10 @@ private synchronized int pid(FilePath ws) throws IOException, InterruptedExcepti
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.
You can’t perform that action at this time.