Skip to content
Permalink
Browse files
[JENKINS-34228] Fixed IOException in DeleteBuildsCommand class
'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 efc1285d67fb7a8e3df2cd1d499a15edc6641d02
Showing with 10 additions and 3 deletions.
  1. +10 −3 core/src/main/java/hudson/cli/DeleteBuildsCommand.java
@@ -29,6 +29,7 @@

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

/**
@@ -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;
}

0 comments on commit efc1285

Please sign in to comment.