File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\cli\SetBuildDisplayNameCommand.java.html

1 package hudson.cli;
2
3 import hudson.Extension;
4 import hudson.model.AbstractProject;
5 import hudson.model.Run;
6 import hudson.remoting.Callable;
7 import org.apache.commons.io.IOUtils;
8 import org.kohsuke.args4j.Argument;
9
10 import java.io.IOException;
11 import java.io.Serializable;
12
13 @Extension
14 public class SetBuildDisplayNameCommand extends CLICommand implements Serializable {
15
16 @Override
17 public String getShortDescription() {
18 return Messages.SetBuildDisplayNameCommand_ShortDescription();
19 }
20
21 @Argument(metaVar="JOB", usage="Name of the job to build", required=true, index=0)
22 public transient AbstractProject<?, ?> job;
23
24 @Argument(metaVar="BUILD#", usage="Number of the build", required=true, index=1)
25 public int number;
26
27 @Argument(metaVar="DISPLAYNAME", required=true, usage="DisplayName to be set. '-' to read from stdin.", index=2)
28 public String displayName;
29
30 protected int run() throws Exception {
31 Run run = job.getBuildByNumber(number);
32 run.checkPermission(Run.UPDATE);
33
34 if ("-".equals(displayName)) {
35 displayName = IOUtils.toString(stdin);
36 }
37
38 run.setDisplayName(displayName);
39
40 return 0;
41 }
42
43 }
44