本文整理了Java中hudson.model.Job.getBuildByNumber()
方法的一些代码示例,展示了Job.getBuildByNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.getBuildByNumber()
方法的具体详情如下:
包路径:hudson.model.Job
类名称:Job
方法名:getBuildByNumber
暂无
代码示例来源:origin: jenkinsci/jenkins
void onLoad(@Nonnull Job,?> job, int buildNumber) {
Run,?> build = job.getBuildByNumber(buildNumber);
if (build != null) {
onLoad(build);
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Gets the {@link Job} that this pointer points to,
* or null if such a job no longer exists.
*/
public Run getRun() {
Job j = getJob();
if(j==null) return null;
return j.getBuildByNumber(number);
}
代码示例来源:origin: jenkinsci/jenkins
public void find(String token, List
try {
if (token.startsWith("#"))
token = token.substring(1); // ignore leading '#'
int n = Integer.parseInt(token);
Run b = getBuildByNumber(n);
if (b == null)
return; // no such build
result.add(SearchItems.create("#" + n, "" + n, b));
} catch (NumberFormatException e) {
// not a number.
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public Object fromString(String string) {
String[] split = string.split("#");
String projectName = split[0];
int buildNumber = Integer.parseInt(split[1]);
Job,?> job = (Job,?>) Jenkins.getInstance().getItemByFullName(projectName);
if(job==null) throw new NoSuchElementException("No such job exists: "+projectName);
Run,?> run = job.getBuildByNumber(buildNumber);
if(run==null) throw new NoSuchElementException("No such build: "+string);
return run;
}
代码示例来源:origin: jenkinsci/jenkins
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);
}
run.setDescription(description);
return 0;
}
代码示例来源:origin: jenkinsci/jenkins
@Override
protected int run() throws Exception {
Run, ?> run = job.getBuildByNumber(number);
if (run == null) {
throw new IllegalArgumentException("Build #" + number + " does not exist");
}
run.checkPermission(Run.UPDATE);
if ("-".equals(displayName)) {
displayName = IOUtils.toString(stdin);
}
run.setDisplayName(displayName);
return 0;
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* @since 1.505
*/
public @CheckForNull Run,?> getUpstreamRun() {
Job,?> job = Jenkins.getInstance().getItemByFullName(upstreamProject, Job.class);
return job != null ? job.getBuildByNumber(upstreamBuild) : null;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Tries to find a run from an persisted identifier.
* @param id as produced by {@link #getExternalizableId}
* @return the same run, or null if the job or run was not found
* @throws IllegalArgumentException if the ID is malformed
*/
public @CheckForNull static Run,?> fromExternalizableId(String id) throws IllegalArgumentException {
int hash = id.lastIndexOf('#');
if (hash <= 0) {
throw new IllegalArgumentException("Invalid id");
}
String jobName = id.substring(0, hash);
int number;
try {
number = Integer.parseInt(id.substring(hash + 1));
} catch (NumberFormatException x) {
throw new IllegalArgumentException(x);
}
Jenkins j = Jenkins.getInstanceOrNull();
if (j == null) {
return null;
}
Job,?> job = j.getItemByFullName(jobName, Job.class);
if (job == null) {
return null;
}
return job.getBuildByNumber(number);
}
代码示例来源:origin: jenkinsci/jenkins
@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");
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* If the command is currently running inside a build, return it. Otherwise null.
*/
protected Run optCurrentlyBuilding() throws CmdLineException {
try {
CLICommand c = CLICommand.getCurrent();
if (c==null)
throw new IllegalStateException("Not executing a CLI command");
String[] envs = c.checkChannel().call(new GetCharacteristicEnvironmentVariables());
if (envs[0]==null || envs[1]==null)
return null;
Job j = Jenkins.getActiveInstance().getItemByFullName(envs[0],Job.class);
if (j==null)
throw new IllegalArgumentException("No such job: "+envs[0]);
try {
Run r = j.getBuildByNumber(Integer.parseInt(envs[1]));
if (r==null)
throw new IllegalArgumentException("No such build #"+envs[1]+" in "+envs[0]);
if (!r.isBuilding()) {
throw new IllegalStateException(r + " is not currently being built");
}
return r;
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid build number: "+envs[1]);
}
} catch (IOException | InterruptedException e) {
throw new IllegalArgumentException("Failed to identify the build being executed",e);
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public Object getDynamic(String token, StaplerRequest req,
StaplerResponse rsp) {
try {
// try to interpret the token as build number
return getBuildByNumber(Integer.parseInt(token));
} catch (NumberFormatException e) {
// try to map that to widgets
for (Widget w : getWidgets()) {
if (w.getUrlName().equals(token))
return w;
}
// is this a permalink?
for (Permalink p : getPermalinks()) {
if(p.getId().equals(token))
return p.resolve(this);
}
return super.getDynamic(token, req, rsp);
}
}
代码示例来源:origin: jenkinsci/jenkins
run = job.getBuildByNumber(n);
if (run==null)
throw new IllegalArgumentException("No such build #"+n);
代码示例来源:origin: jenkinsci/jenkins
if(!includeMissing && job.getBuildByNumber(bp.getNumber())==null)
continue; // build no longer exists
代码示例来源:origin: jenkinsci/jenkins
if (n==RESOLVES_TO_NONE) return null;
b = job.getBuildByNumber(n);
if (b!=null && apply(b))
return b; // found it (in the most efficient way possible)
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Gets the {@link Job} that this pointer points to,
* or null if such a job no longer exists.
*/
public Run getRun() {
Job j = getJob();
if(j==null) return null;
return j.getBuildByNumber(number);
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Gets the {@link Job} that this pointer points to,
* or null if such a job no longer exists.
*/
public Run getRun() {
Job j = getJob();
if(j==null) return null;
return j.getBuildByNumber(number);
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
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);
}
run.setDescription(description);
return 0;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* @since 1.505
*/
public @CheckForNull Run,?> getUpstreamRun() {
Job,?> job = Jenkins.getInstance().getItemByFullName(upstreamProject, Job.class);
return job != null ? job.getBuildByNumber(upstreamBuild) : null;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@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");
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
@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");
}
}