Skip to content
Permalink
Browse files
[JENKINS-13554] Do not keep locked builds
  • Loading branch information
olivergondza committed Jan 4, 2015
1 parent 4e22a02 commit 815b8d08c4b11ec3315ef8745b2554d663c0b5ac
Showing 2 changed files with 35 additions and 5 deletions.
@@ -93,16 +93,13 @@ public Object readResolve() {
/**
* Delete build and its child builds.
*
* Child builds can be skipped if they have to be kept.
*
* @since TODO
*/
@Override
public void delete() throws IOException {
super.delete();

for(MatrixRun run : getExactRuns()) {
if (run.getWhyKeepLog() != null) continue;
run.delete();
}
}
@@ -559,7 +559,40 @@ public class MatrixProjectTest {
assertThat(build.getWorkspace().getRemote(), containsString("/workspace/shortName/${build.parent.digestName}"));
}

@Test
@Test @Issue("JENKINS-13554")
public void deletedLockedParentBuild() {
MatrixProject p = j.jenkins.createProject(MatrixProject.class, "project");
p.setAxes(new AxisList(new TextAxis("AXIS", "VALUE")));
def build = p.scheduleBuild2(0).get();
def c = p.getItem("AXIS=VALUE");

build.keepLog();

build.delete();

assertEquals("parent build is deleted", 0, p.builds.size());
assertEquals("child build is deleted", 0, c.builds.size());
}

@Test @Issue("JENKINS-13554")
public void deletedParentBuildWithLockedChildren() {
MatrixProject p = j.jenkins.createProject(MatrixProject.class, "project");
p.setAxes(new AxisList(new TextAxis("AXIS", "VALUE")));
def build = p.scheduleBuild2(0).get();
p.scheduleBuild2(0).get();

def c = p.getItem("AXIS=VALUE");

c.getBuildByNumber(2).delete(); // delete newest run
assertNotNull(c.getBuildByNumber(1).getWhyKeepLog());

build.delete();

assertEquals("last parent build should be kept", 1, p.builds.size());
assertEquals("child builds are deleted", 0, c.builds.size());
}

@Test @Issue("JENKINS-13554")
public void discardBuilds() {
MatrixProject p = j.jenkins.createProject(MatrixProject.class, "discarder");
p.setAxes(new AxisList(new TextAxis("AXIS", "VALUE")));
@@ -600,7 +633,7 @@ public class MatrixProjectTest {
assertEquals(1, last.artifacts.size());
}

@Test
@Test @Issue("JENKINS-13554")
public void deleteBuildWithChildrenOverCLI() {
MatrixProject p = j.jenkins.createProject(MatrixProject.class, "project");
p.setAxes(new AxisList(new TextAxis("AXIS", "VALUE")));

0 comments on commit 815b8d0

Please sign in to comment.