Search in sources :

Example 6 with AbstractBuild

use of hudson.model.AbstractBuild 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)

Example 7 with AbstractBuild

use of hudson.model.AbstractBuild in project promoted-builds-plugin by jenkinsci.

the class DownstreamPassCondition method isMet.

@Override
public PromotionBadge isMet(PromotionProcess promotionProcess, AbstractBuild<?, ?> build) {
    Badge badge = new Badge();
    PseudoDownstreamBuilds pdb = build.getAction(PseudoDownstreamBuilds.class);
    EnvVars buildEnvironment = new EnvVars(build.getBuildVariables());
    OUTER: for (AbstractProject<?, ?> j : getJobList(build.getProject().getParent(), buildEnvironment)) {
        for (AbstractBuild<?, ?> b : build.getDownstreamBuilds(j)) {
            if (!b.isBuilding()) {
                Result r = b.getResult();
                if ((r == Result.SUCCESS) || (evenIfUnstable && r == Result.UNSTABLE)) {
                    badge.add(b);
                    continue OUTER;
                }
            }
        }
        if (pdb != null) {
            // if fingerprint doesn't have any, try the pseudo-downstream
            for (AbstractBuild<?, ?> b : pdb.listBuilds(j)) {
                if (!b.isBuilding()) {
                    Result r = b.getResult();
                    if ((r == Result.SUCCESS) || (evenIfUnstable && r == Result.UNSTABLE)) {
                        badge.add(b);
                        continue OUTER;
                    }
                }
            }
        }
        // none of the builds of this job passed.
        return null;
    }
    return badge;
}
Also used : EnvVars(hudson.EnvVars) AbstractBuild(hudson.model.AbstractBuild) PromotionBadge(hudson.plugins.promoted_builds.PromotionBadge) AbstractProject(hudson.model.AbstractProject) Result(hudson.model.Result)

Example 8 with AbstractBuild

use of hudson.model.AbstractBuild in project promoted-builds-plugin by jenkinsci.

the class KeepBuildForeverAction method perform.

@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    PrintStream console = listener.getLogger();
    // only applicable to promotions, so should be impossible not to be one, but check anyway
    if (!(build instanceof Promotion)) {
        console.println(Messages.KeepBuildForEverAction_console_notPromotion());
        build.setResult(Result.FAILURE);
        return false;
    }
    final Result buildResult = build.getResult();
    if (buildResult != null && buildResult.isWorseThan(PROMOTION_RESULT_MUST_BE_AT_LEAST)) {
        console.println(Messages.KeepBuildForEverAction_console_promotionNotGoodEnough(build.getResult()));
        return true;
    }
    AbstractBuild promoted = ((Promotion) build).getTarget();
    console.println(Messages.KeepBuildForEverAction_console_keepingBuild());
    promoted.keepLog();
    return true;
}
Also used : PrintStream(java.io.PrintStream) AbstractBuild(hudson.model.AbstractBuild) Result(hudson.model.Result)

Aggregations

AbstractBuild (hudson.model.AbstractBuild)8 AbstractProject (hudson.model.AbstractProject)2 Result (hudson.model.Result)2 ArrayList (java.util.ArrayList)2 AbortException (hudson.AbortException)1 EnvVars (hudson.EnvVars)1 FilePath (hudson.FilePath)1 PermalinkList (hudson.PermalinkList)1 WorkspaceSnapshot (hudson.WorkspaceSnapshot)1 Fingerprint (hudson.model.Fingerprint)1 FingerprintMap (hudson.model.FingerprintMap)1 Hudson (hudson.model.Hudson)1 ParameterDefinition (hudson.model.ParameterDefinition)1 ParameterValue (hudson.model.ParameterValue)1 ParametersAction (hudson.model.ParametersAction)1 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)1 Permalink (hudson.model.PermalinkProjectAction.Permalink)1 PromotionBadge (hudson.plugins.promoted_builds.PromotionBadge)1 VirtualChannel (hudson.remoting.VirtualChannel)1 Entry (hudson.scm.ChangeLogSet.Entry)1