Skip to content

Commit

Permalink
[JENKINS-34228] Fixed IOException in DeleteBuildsCommand class
Browse files Browse the repository at this point in the history
'delete-builds' CLi can be invoked with more occurence of the same
build number. Handle such a situation is responsibility of the
command impl. itself.
  • Loading branch information
pjanouse committed Apr 18, 2016
1 parent ca1cc0e commit efc1285
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/src/main/java/hudson/cli/DeleteBuildsCommand.java
Expand Up @@ -29,6 +29,7 @@

import java.io.IOException;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.List;

/**
Expand All @@ -54,10 +55,16 @@ protected void printUsageSummary(PrintStream stderr) {
protected int act(List<AbstractBuild<?, ?>> builds) throws IOException {
job.checkPermission(Run.DELETE);

for (AbstractBuild build : builds)
build.delete();
final HashSet<Integer> hsBuilds = new HashSet<Integer>();

stdout.println("Deleted "+builds.size()+" builds");
for (AbstractBuild build : builds) {
if (!hsBuilds.contains(build.number)) {
build.delete();
hsBuilds.add(build.number);
}
}

stdout.println("Deleted "+hsBuilds.size()+" builds");

return 0;
}
Expand Down

0 comments on commit efc1285

Please sign in to comment.