Search in sources :

Example 1 with PermalinkList

use of hudson.PermalinkList in project hudson-2.x by hudson.

the class Job method getPermalinks.

/**
 * Gets all the {@link Permalink}s defined for this job.
 *
 * @return never null
 */
public PermalinkList getPermalinks() {
    // TODO: shall we cache this?
    PermalinkList permalinks = new PermalinkList(Permalink.BUILTIN);
    for (Action a : getActions()) {
        if (a instanceof PermalinkProjectAction) {
            PermalinkProjectAction ppa = (PermalinkProjectAction) a;
            permalinks.addAll(ppa.getPermalinks());
        }
    }
    return permalinks;
}
Also used : PermalinkList(hudson.PermalinkList)

Example 2 with PermalinkList

use of hudson.PermalinkList 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);
}
Also used : WorkspaceSnapshot(hudson.WorkspaceSnapshot) Permalink(hudson.model.PermalinkProjectAction.Permalink) WorkspaceSnapshot(hudson.WorkspaceSnapshot) PermalinkList(hudson.PermalinkList) AbstractBuild(hudson.model.AbstractBuild) Hudson(hudson.model.Hudson) AbstractProject(hudson.model.AbstractProject)

Aggregations

PermalinkList (hudson.PermalinkList)2 WorkspaceSnapshot (hudson.WorkspaceSnapshot)1 AbstractBuild (hudson.model.AbstractBuild)1 AbstractProject (hudson.model.AbstractProject)1 Hudson (hudson.model.Hudson)1 Permalink (hudson.model.PermalinkProjectAction.Permalink)1