Skip to content
Permalink
Browse files

[FIXED JENKINS-32701] Escape % in paths passed to bat.

  • Loading branch information
jglick committed Mar 24, 2016
2 parents 66d80d2 + a0b69f1 commit b5e480d43d0bcf3d3020823051bcf06473551e9c
@@ -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");

@@ -49,17 +49,22 @@

@Issue("JENKINS-25678")
@Test public void spaceInPath() throws Exception {
doSpaceInPath("space in path");
testWithPath("space in path");
}

@Issue("JENKINS-25678")
@Test public void spaceInPath2() throws Exception {
doSpaceInPath("space in path@2");
testWithPath("space in path@2");
}

private void doSpaceInPath(String name) throws Exception {
@Issue("JENKINS-32701")
@Test public void percentInPath() throws Exception {
testWithPath("percent%in%path");
}

private void testWithPath(String path) throws Exception {
StreamTaskListener listener = StreamTaskListener.fromStdout();
FilePath ws = j.jenkins.getRootPath().child(name);
FilePath ws = j.jenkins.getRootPath().child(path);
Launcher launcher = j.jenkins.createLauncher(listener);
Controller c = new WindowsBatchScript("echo hello world").launch(new EnvVars(), ws, launcher, listener);
while (c.exitStatus(ws, launcher) == null) {

0 comments on commit b5e480d

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