@Override @CheckForNull public Run<?, ?> getBuild(@Nonnull Job<?, ?> job, @Nonnull RunSelectorContext context) { String resolvedId = context.getEnvVars().expand(id); if (resolvedId.startsWith("$")) { context.logDebug("Unresolved variable {0}", resolvedId); return null; } Permalink p = job.getPermalinks().get(resolvedId); if (p == null) { context.logDebug("No permalink found for {0}", resolvedId); return null; } Run<?, ?> run = p.resolve(job); if (run == null) { context.logDebug("No such build {0} in {1}", id, job.getFullName()); return null; } return run; }
public ComboBoxModel doFillIdItems(@AncestorInPath Job<?, ?> copyingJob, @RelativePath("..") @QueryParameter("projectName") String projectName) { Job<?, ?> j = null; Jenkins jenkins = Jenkins.getInstance(); if (projectName != null && jenkins != null) { j = jenkins.getItem(projectName, copyingJob, Job.class); } ComboBoxModel r = new ComboBoxModel(); for (Permalink p : j != null ? j.getPermalinks() : Permalink.BUILTIN) { r.add(p.getId()); } return r; }