提交 297aff0c 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-9126] added 'set-build-displayname' CLI command.

上级 259477a1
...@@ -77,6 +77,9 @@ Upcoming changes</a> ...@@ -77,6 +77,9 @@ Upcoming changes</a>
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10414">issue 10414</a>) (<a href="https://issues.jenkins-ci.org/browse/JENKINS-10414">issue 10414</a>)
<li class=rfe> <li class=rfe>
Added a dignosis CLI command to report the current granted authorities. Added a dignosis CLI command to report the current granted authorities.
<li class=rfe>
Added a CLI command to set display name of the build
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9126">issue 9126</a>)
<li class=rfe> <li class=rfe>
Added an option in CLI build command to check for SCM changes before carrying out a build Added an option in CLI build command to check for SCM changes before carrying out a build
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9968">issue 9968</a>) (<a href="https://issues.jenkins-ci.org/browse/JENKINS-9968">issue 9968</a>)
......
package hudson.cli;
import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Run;
import hudson.remoting.Callable;
import org.apache.commons.io.IOUtils;
import org.kohsuke.args4j.Argument;
import java.io.IOException;
import java.io.Serializable;
@Extension
public class SetBuildDisplayNameCommand extends CLICommand implements Serializable {
@Override
public String getShortDescription() {
return "Sets the displayName of a build";
}
@Argument(metaVar="JOB", usage="Name of the job to build", required=true, index=0)
public transient AbstractProject<?, ?> job;
@Argument(metaVar="BUILD#", usage="Number of the build", required=true, index=1)
public int number;
@Argument(metaVar="DISPLAYNAME", required=true, usage="DisplayName to be set. '-' to read from stdin.", index=2)
public String displayName;
protected int run() throws Exception {
Run run = job.getBuildByNumber(number);
run.checkPermission(Run.UPDATE);
if ("-".equals(displayName)) {
displayName = channel.call(new Callable<String, IOException>() {
public String call() throws IOException {
return IOUtils.toString(System.in);
}
});
}
run.setDisplayName(displayName);
return 0;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册