/** * Get parser for this command. * * Exposed to be overridden by {@link hudson.cli.declarative.CLIRegisterer}. * @since 1.538 */ protected CmdLineParser getCmdLineParser() { return new CmdLineParser(this); }
@Override public boolean hidden() { return base.hidden(); } }
public Class<? extends Annotation> annotationType() { return base.annotationType(); }
/** * {@link CLICommand} that acts on a series of {@link Run}s. * @since 2.62 */ public abstract class RunRangeCommand extends CLICommand { @Argument(metaVar="JOB",usage="Name of the job to build",required=true,index=0) public Job<?,?> job; @Argument(metaVar="RANGE",usage="Range of the build records to delete. 'N-M', 'N,M', or 'N'",required=true,index=1) public String range; protected int run() throws Exception { RangeSet rs = RangeSet.fromString(range,false); return act((List)job.getBuilds(rs)); } protected abstract int act(List<Run<?,?>> builds) throws IOException; }
protected void printUsage(PrintStream stderr, CmdLineParser p) { stderr.print("java -jar jenkins-cli.jar " + getName()); p.printSingleLineUsage(stderr); stderr.println(); printUsageSummary(stderr); p.printUsage(stderr); }
@CLIResolver public RunT getBuildForCLI(@Argument(required=true,metaVar="BUILD#",usage="Build number") String id) throws CmdLineException { try { int n = Integer.parseInt(id); RunT r = getBuildByNumber(n); if (r==null) throw new CmdLineException(null, "No such build '#"+n+"' exists"); return r; } catch (NumberFormatException e) { throw new CmdLineException(null, id+ "is not a number"); } }
public int index() { return base.index()+bias; }
public String usage() { return base.usage(); }
public String metaVar() { return base.metaVar(); }
public boolean multiValued() { return base.multiValued(); }
public boolean required() { return base.required(); }
public Class<? extends OptionHandler> handler() { return base.handler(); }
/** * {@link CLICommand} that acts on a series of {@link AbstractBuild}s. * * @author Kohsuke Kawaguchi * @deprecated rather use {@link RunRangeCommand} */ @Deprecated public abstract class AbstractBuildRangeCommand extends CLICommand { @Argument(metaVar="JOB",usage="Name of the job to build",required=true,index=0) public AbstractProject<?,?> job; @Argument(metaVar="RANGE",usage="Range of the build records to delete. 'N-M', 'N,M', or 'N'",required=true,index=1) public String range; protected int run() throws Exception { RangeSet rs = RangeSet.fromString(range,false); return act((List)job.getBuilds(rs)); } protected abstract int act(List<AbstractBuild<?,?>> builds) throws IOException; }
/** * Used for CLI binding. */ @CLIResolver public static AbstractProject resolveForCLI( @Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException { AbstractProject item = Jenkins.getInstance().getItemByFullName(name, AbstractProject.class); if (item==null) { AbstractProject project = AbstractProject.findNearest(name); throw new CmdLineException(null, project == null ? Messages.AbstractItem_NoSuchJobExistsWithoutSuggestion(name) : Messages.AbstractItem_NoSuchJobExists(name, project.getFullName())); } return item; }
/** * @author Kohsuke Kawaguchi */ @Extension public class GetJobCommand extends CLICommand { @Argument(metaVar="JOB",usage="Name of the job",required=true) public AbstractItem job; @Override public String getShortDescription() { return Messages.GetJobCommand_ShortDescription(); } protected int run() throws Exception { job.writeConfigDotXml(stdout); return 0; } }
/** * @author Kohsuke Kawaguchi */ @Extension public class UpdateJobCommand extends CLICommand { @Argument(metaVar="JOB",usage="Name of the job",required=true) public AbstractItem job; @Override public String getShortDescription() { return Messages.UpdateJobCommand_ShortDescription(); } protected int run() throws Exception { job.updateByXml((Source)new StreamSource(stdin)); return 0; } }
/** * @author ogondza * @since 1.526 */ @Extension public class UpdateNodeCommand extends CLICommand { @Argument(metaVar="NODE", usage="Name of the node", required=true) public Node node; @Override public String getShortDescription() { return Messages.UpdateNodeCommand_ShortDescription(); } @Override protected int run() throws IOException, ServletException { node.toComputer().updateByXml(stdin); return 0; } }
/** * @author ogondza * @since 1.538 */ @Extension public class UpdateViewCommand extends CLICommand { @Argument(usage="Name of the view to update", required=true) private View view; @Override public String getShortDescription() { return Messages.UpdateViewCommand_ShortDescription(); } @Override protected int run() throws Exception { view.updateByXml(new StreamSource(stdin)); return 0; } }
/** * CLI command, which waits till the node switches to the online state. * @author pjanouse * @since 2.16 */ @Extension public class WaitNodeOnlineCommand extends CLICommand { @Argument(metaVar="NODE", usage="Name of the node", required=true) public Node node; @Override public String getShortDescription() { return Messages.WaitNodeOnlineCommand_ShortDescription(); } @Override protected int run() throws Exception { node.toComputer().waitUntilOnline(); return 0; } }
/** * @author ogondza * @since 1.526 */ @Extension public class GetNodeCommand extends CLICommand { @Argument(metaVar="NODE", usage="Name of the node", required=true) public Node node; @Override public String getShortDescription() { return Messages.GetNodeCommand_ShortDescription(); } @Override protected int run() throws IOException { node.checkPermission(Computer.EXTENDED_READ); Jenkins.XSTREAM2.toXMLUTF8(node, stdout); return 0; } }