Skip to content
Permalink
Browse files

[FIXED JENKINS-17138] Deleting/renaming jobs using external builds di…

…rectory does not move builds.
  • Loading branch information
jglick committed Mar 9, 2013
1 parent b90b202 commit d98716dfbad96f566938b90a5a8b50ce9765575b
@@ -67,6 +67,9 @@
<li class=bug>
Permalinks created in the wrong place when using external build directories.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17137">issue 17137</a>)
<li class=bug>
External build directories not updated by job rename/delete.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17138">issue 17138</a>)
<li class=bug>
JNA-related error from Windows slave monitoring thrown repeatedly.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15796">issue 15796</a>)
@@ -573,7 +573,19 @@ public String getNextKey(String key) {
*/
@Override
public void renameTo(String newName) throws IOException {
File oldBuildDir = getBuildDir();
super.renameTo(newName);
File newBuildDir = getBuildDir();
if (oldBuildDir.isDirectory() && !newBuildDir.isDirectory()) {
if (!oldBuildDir.renameTo(newBuildDir)) {
throw new IOException("failed to rename " + oldBuildDir + " to " + newBuildDir);
}
}
}

@Override public synchronized void delete() throws IOException, InterruptedException {
super.delete();
Util.deleteRecursive(getBuildDir());
}

/**
@@ -354,4 +354,24 @@ public void testExternalBuildDirectorySymlinks() throws Exception {
assertFalse(link.exists());
}

@Bug(17138)
public void testExternalBuildDirectoryRenameDelete() throws Exception {
HtmlForm form = new WebClient().goTo("configure").getFormByName("config");
File builds = createTmpDir();
form.getInputByName("_.rawBuildsDir").setValueAttribute(builds + "/${ITEM_FULL_NAME}");
submit(form);
assertEquals(builds + "/${ITEM_FULL_NAME}", jenkins.getRawBuildsDir());
FreeStyleProject p = jenkins.createProject(MockFolder.class, "d").createProject(FreeStyleProject.class, "prj");
FreeStyleBuild b = p.scheduleBuild2(0).get();
File oldBuildDir = new File(builds, "d/prj");
assertEquals(new File(oldBuildDir, b.getId()), b.getRootDir());
assertTrue(b.getRootDir().isDirectory());
p.renameTo("proj");
File newBuildDir = new File(builds, "d/proj");
assertEquals(new File(newBuildDir, b.getId()), b.getRootDir());
assertTrue(b.getRootDir().isDirectory());
p.delete();
assertFalse(b.getRootDir().isDirectory());
}

}

0 comments on commit d98716d

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