From 685fc6d373b4648ecc63efe748b1dd40ae4d5b62 Mon Sep 17 00:00:00 2001 From: Sam Van Oort Date: Thu, 8 Mar 2018 09:39:33 -0500 Subject: [PATCH 1/2] Fix missing carriage return in batch file durable task --- .../org/jenkinsci/plugins/durabletask/WindowsBatchScript.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java b/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java index 4d4ec94d..ff3d35a1 100644 --- a/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java +++ b/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java @@ -68,7 +68,7 @@ public String getScript() { quote(c.getLogFile(ws)), quotedResultFile, quotedResultFile, quotedResultFile); } else { - cmd = String.format("@echo off \r\ncmd /c \"\"%s\"\" > \"%s\" 2>&1\r\necho %%ERRORLEVEL%% > \"%s.tmp\"\r\nmove \"%s.tmp\" \"%s\"\n", + cmd = String.format("@echo off \r\ncmd /c \"\"%s\"\" > \"%s\" 2>&1\r\necho %%ERRORLEVEL%% > \"%s.tmp\"\r\nmove \"%s.tmp\" \"%s\"\r\n", quote(c.getBatchFile2(ws)), quote(c.getLogFile(ws)), quotedResultFile, quotedResultFile, quotedResultFile); From 8513d0c1619db2a54fefa2294ab8b5775fc4cab7 Mon Sep 17 00:00:00 2001 From: Sam Van Oort Date: Thu, 8 Mar 2018 11:25:19 -0500 Subject: [PATCH 2/2] Fully back out the changes from #66 that introduced inexplicable hang bugs on windows --- .../plugins/durabletask/WindowsBatchScript.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java b/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java index ff3d35a1..7fac3075 100644 --- a/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java +++ b/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java @@ -60,18 +60,17 @@ public String getScript() { BatchController c = new BatchController(ws); String cmd; - String quotedResultFile = quote(c.getResultFile(ws)); if (capturingOutput) { - cmd = String.format("@echo off \r\ncmd /c \"\"%s\"\" > \"%s\" 2> \"%s\"\r\necho %%ERRORLEVEL%% > \"%s.tmp\"\r\nmove \"%s.tmp\" \"%s\"\r\n", + cmd = String.format("@echo off \r\ncmd /c \"\"%s\"\" > \"%s\" 2> \"%s\"\r\necho %%ERRORLEVEL%% > \"%s\"\r\n", quote(c.getBatchFile2(ws)), quote(c.getOutputFile(ws)), quote(c.getLogFile(ws)), - quotedResultFile, quotedResultFile, quotedResultFile); + quote(c.getResultFile(ws))); } else { - cmd = String.format("@echo off \r\ncmd /c \"\"%s\"\" > \"%s\" 2>&1\r\necho %%ERRORLEVEL%% > \"%s.tmp\"\r\nmove \"%s.tmp\" \"%s\"\r\n", + cmd = String.format("@echo off \r\ncmd /c \"\"%s\"\" > \"%s\" 2>&1\r\necho %%ERRORLEVEL%% > \"%s\"\r\n", quote(c.getBatchFile2(ws)), quote(c.getLogFile(ws)), - quotedResultFile, quotedResultFile, quotedResultFile); + quote(c.getResultFile(ws))); } c.getBatchFile1(ws).write(cmd, "UTF-8"); c.getBatchFile2(ws).write(script, "UTF-8");