use of hudson.model.PermalinkProjectAction.Permalink in project hudson-2.x by hudson.
the class WorkspaceSnapshotSCM method resolve.
/**
* Obtains the {@link WorkspaceSnapshot} object that this {@link SCM} points to,
* or throws {@link ResolvedFailedException} upon failing.
*
* @return never null.
*/
public Snapshot resolve() throws ResolvedFailedException {
Hudson h = Hudson.getInstance();
AbstractProject<?, ?> job = h.getItemByFullName(jobName, AbstractProject.class);
if (job == null) {
if (h.getItemByFullName(jobName) == null) {
AbstractProject nearest = AbstractProject.findNearest(jobName);
throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchJob(jobName, nearest.getFullName()));
} else
throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_IncorrectJobType(jobName));
}
PermalinkList permalinks = job.getPermalinks();
Permalink p = permalinks.get(permalink);
if (p == null)
throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoSuchPermalink(permalink, jobName));
AbstractBuild<?, ?> b = (AbstractBuild<?, ?>) p.resolve(job);
if (b == null)
throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoBuild(permalink, jobName));
WorkspaceSnapshot snapshot = b.getAction(WorkspaceSnapshot.class);
if (snapshot == null)
throw new ResolvedFailedException(Messages.WorkspaceSnapshotSCM_NoWorkspace(jobName, permalink));
return new Snapshot(snapshot, b);
}
use of hudson.model.PermalinkProjectAction.Permalink in project hudson-2.x by hudson.
the class PermalinkList method findNearest.
/**
* Finds the closest name match by its ID.
*/
public Permalink findNearest(String id) {
List<String> ids = new ArrayList<String>();
for (Permalink p : this) ids.add(p.getId());
String nearest = EditDistance.findNearest(id, ids);
if (nearest == null)
return null;
return get(nearest);
}
Aggregations