/hudson-core/src/main/java/hudson/cli/AbstractBuildRangeCommand.java

http://github.com/hudson/hudson · Java · 30 lines · 18 code · 7 blank · 5 comment · 0 complexity · 28b3b30794f157b9b7fb1203e00f8132 MD5 · raw file

  1. package hudson.cli;
  2. import hudson.model.AbstractBuild;
  3. import hudson.model.AbstractProject;
  4. import hudson.model.Fingerprint.RangeSet;
  5. import org.kohsuke.args4j.Argument;
  6. import java.io.IOException;
  7. import java.util.List;
  8. /**
  9. * {@link CLICommand} that acts on a series of {@link AbstractBuild}s.
  10. *
  11. * @author Kohsuke Kawaguchi
  12. */
  13. public abstract class AbstractBuildRangeCommand extends CLICommand {
  14. @Argument(metaVar="JOB",usage="Name of the job to build",required=true,index=0)
  15. public AbstractProject<?,?> job;
  16. @Argument(metaVar="RANGE",usage="Range of the build records to delete. 'N-M', 'N,M', or 'N'",required=true,index=1)
  17. public String range;
  18. protected int run() throws Exception {
  19. RangeSet rs = RangeSet.fromString(range,false);
  20. return act((List)job.getBuilds(rs));
  21. }
  22. protected abstract int act(List<AbstractBuild<?,?>> builds) throws IOException;
  23. }