forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetBuildDescriptionCommand.java
More file actions
48 lines (36 loc) · 1.55 KB
/
SetBuildDescriptionCommand.java
File metadata and controls
48 lines (36 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package hudson.cli;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.model.Job;
import hudson.model.Run;
import java.io.Serializable;
import org.apache.commons.io.IOUtils;
import org.kohsuke.args4j.Argument;
// TODO: Remove Serializable
@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "The Serializable should be removed.")
@Extension
public class SetBuildDescriptionCommand extends CLICommand implements Serializable {
@Override
public String getShortDescription() {
return Messages.SetBuildDescriptionCommand_ShortDescription();
}
@Argument(metaVar = "JOB", usage = "Name of the job to build", required = true, index = 0)
public transient Job<?, ?> job;
@Argument(metaVar = "BUILD#", usage = "Number of the build", required = true, index = 1)
public int number;
@Argument(metaVar = "DESCRIPTION", required = true, usage = "Description to be set. '=' to read from stdin.", index = 2)
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility")
public String description;
@Override
protected int run() throws Exception {
Run<?, ?> run = job.getBuildByNumber(number);
if (run == null)
throw new IllegalArgumentException("No such build #" + number);
run.checkPermission(Run.UPDATE);
if ("=".equals(description)) {
description = IOUtils.toString(stdin, getClientCharset());
}
run.setDescription(description);
return 0;
}
}