Skip to content
Permalink
Browse files

Escape percentage signs in the jenkins-wrapper batch script.

When writing workspace paths into the `jenkins-wrapper.bat` batch
script, percentage signs need to be escaped correctly. Otherwise
the batch script execution will silently fail when the workspace
path contains a percentage sign. This was encountered in a multi branch
workflow project.
  • Loading branch information...
arthurschreiber committed Jan 21, 2016
1 parent 7f14ad2 commit 9fbcb7f22062bbd1077d793ed8c9b1697da4052c
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/main/java/org/jenkinsci/plugins/durabletask/WindowsBatchScript.java
@@ -55,9 +55,9 @@ public String getScript() {
BatchController c = new BatchController(ws);

c.getBatchFile1(ws).write(String.format("cmd /c \"%s\" > \"%s\" 2>&1\r\necho %%ERRORLEVEL%% > \"%s\"\r\n",
c.getBatchFile2(ws),
c.getLogFile(ws),
c.getResultFile(ws)
c.getBatchFile2(ws).getRemote().replace("%", "%%"),
c.getLogFile(ws).getRemote().replace("%", "%%"),
c.getResultFile(ws).getRemote().replace("%", "%%")
), "UTF-8");
c.getBatchFile2(ws).write(script, "UTF-8");

0 comments on commit 9fbcb7f

Please sign in to comment.
You can’t perform that action at this time.