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);
}
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;
}
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;
}
Aggregations