Search in sources :

Example 1 with LazyBuildMixIn

use of jenkins.model.lazy.LazyBuildMixIn in project blueocean-plugin by jenkinsci.

the class RunSearch method findRuns.

@SuppressWarnings("unchecked")
public static Iterable<BlueRun> findRuns(Job job, final Link parent, int start, int limit) {
    final List<BlueRun> runs = new ArrayList<>();
    Iterable<Job> pipelines;
    if (job != null) {
        pipelines = ImmutableList.of(job);
    } else {
        pipelines = Jenkins.getInstance().getItems(Job.class);
    }
    for (Job p : pipelines) {
        Iterator<? extends Run> runIterator;
        if (job instanceof LazyBuildMixIn.LazyLoadingJob) {
            final LazyBuildMixIn lazyLoadMixin = ((LazyBuildMixIn.LazyLoadingJob) job).getLazyBuildMixIn();
            runIterator = lazyLoadMixin.getRunMap().iterator();
        } else {
            runIterator = p.getBuilds().iterator();
        }
        runs.addAll(collectRuns(runIterator, parent, start, limit));
    }
    return runs;
}
Also used : LazyBuildMixIn(jenkins.model.lazy.LazyBuildMixIn) BlueRun(io.jenkins.blueocean.rest.model.BlueRun) ArrayList(java.util.ArrayList) Job(hudson.model.Job)

Aggregations

Job (hudson.model.Job)1 BlueRun (io.jenkins.blueocean.rest.model.BlueRun)1 ArrayList (java.util.ArrayList)1 LazyBuildMixIn (jenkins.model.lazy.LazyBuildMixIn)1