diff --git a/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java b/src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java index 4d4ec94d..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\"\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");