/** * @since 1.517 * @return Returns a list of builds, filtered based on the filter value. */ public RunList getBuilds() { // use getFilter() method so we dont have to worry about null filter value. switch (getFilter()) { case COMPLETED: return getProject().getBuilds().overThresholdOnly(Result.ABORTED).completedOnly(); case SUCCESSFUL: return getProject().getBuilds().overThresholdOnly(Result.UNSTABLE).completedOnly(); case STABLE : return getProject().getBuilds().overThresholdOnly(Result.SUCCESS).completedOnly(); default: return getProject().getBuilds(); } }
@Override public boolean shouldClearAll(@Nonnull Run<?,?> build) { if (build instanceof WorkflowRun) { WorkflowRun r = (WorkflowRun)build; WorkflowJob j = r.getParent(); PreserveStashesJobProperty prop = j.getProperty(PreserveStashesJobProperty.class); if (prop != null) { int bc = prop.getBuildCount(); if (bc > 0) { for (WorkflowRun recentRun : j.getBuilds().completedOnly().limit(bc)) { if (recentRun != null && recentRun.equals(r)) { return false; } } } } } return true; } }
/** * @since 1.517 * @return Returns a list of builds, filtered based on the filter value. */ public RunList getBuilds() { // use getFilter() method so we dont have to worry about null filter value. switch (getFilter()) { case COMPLETED: return getProject().getBuilds().overThresholdOnly(Result.ABORTED).completedOnly(); case SUCCESSFUL: return getProject().getBuilds().overThresholdOnly(Result.UNSTABLE).completedOnly(); case STABLE : return getProject().getBuilds().overThresholdOnly(Result.SUCCESS).completedOnly(); default: return getProject().getBuilds(); } }
@Override public void onCompleted(Run<?,?> r, TaskListener listener) { if (r instanceof WorkflowRun) { WorkflowJob j = ((WorkflowRun) r).getParent(); PreserveStashesJobProperty prop = j.getProperty(PreserveStashesJobProperty.class); if (prop != null && prop.getBuildCount() > 0) { // The "+1" is to ensure that we look at one more than the maximum possible number of builds with saved stashes. for (WorkflowRun build : j.getBuilds().completedOnly().limit(MAX_SAVED_STASHES + 1)) { try { StashManager.maybeClearAll(build); } catch (IOException x) { LOGGER.log(Level.WARNING, "failed to clean up stashes from " + build, x); } } } } } }