提交 7f4014c7 编写于 作者: D Daniel Beck

[FIXED JENKINS-19764] Ensure parent dir of new builds dir exists.

上级 fd772948
......@@ -619,6 +619,9 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
super.renameTo(newName);
File newBuildDir = getBuildDir();
if (oldBuildDir.isDirectory() && !newBuildDir.isDirectory()) {
if (!newBuildDir.getParentFile().isDirectory()) {
newBuildDir.getParentFile().mkdirs();
}
if (!oldBuildDir.renameTo(newBuildDir)) {
throw new IOException("failed to rename " + oldBuildDir + " to " + newBuildDir);
}
......
......@@ -2014,6 +2014,11 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
return buildsDir;
}
@Restricted(NoExternalUse.class)
public void setRawBuildsDir(String buildsDir) {
this.buildsDir = buildsDir;
}
public FilePath getRootPath() {
return new FilePath(getRootDir());
}
......
......@@ -277,4 +277,12 @@ public class JobTest {
}).intValue());
}
@Bug(19764)
@Test public void testRenameWithCustomBuildsDirWithSubdir() throws Exception {
j.jenkins.setRawBuildsDir("${JENKINS_HOME}/builds/${ITEM_FULL_NAME}/builds");
final FreeStyleProject p = j.createFreeStyleProject();
p.scheduleBuild2(0).get();
p.renameTo("different-name");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册