use of hudson.plugins.promoted_builds.PromotedProjectAction in project promoted-builds-plugin by jenkinsci.
the class PromotedBuildParameterDefinition method getRuns.
/**
* Gets a list of promoted builds for the project.
* @param base Base item for the relative addressing
* @return List of {@link AbstractBuild}s, which have been promoted.
* May return an empty list if {@link Jenkins} instance is not ready
* @since 2.22
*/
@Nonnull
public List<Run<?, ?>> getRuns(@CheckForNull Item base) {
final List<Run<?, ?>> runs = new ArrayList<Run<?, ?>>();
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
return runs;
}
// JENKINS-25011: also look for jobs in folders.
final AbstractProject<?, ?> job = ItemPathResolver.getByPath(projectName, base, AbstractProject.class);
if (job == null) {
return runs;
}
PromotedProjectAction promotedProjectAction = job.getAction(PromotedProjectAction.class);
if (promotedProjectAction == null) {
return runs;
}
for (Run<?, ?> run : job.getBuilds()) {
List<PromotedBuildAction> actions = run.getActions(PromotedBuildAction.class);
for (PromotedBuildAction buildAction : actions) {
if (buildAction.contains(promotionProcessName)) {
runs.add(run);
break;
}
}
}
return runs;
}
Aggregations