use of hudson.model.TopLevelItem in project blueocean-plugin by jenkinsci.
the class RunSearch method search.
@Override
public Pageable<BlueRun> search(Query q) {
String pipeline = q.param("pipeline", false);
boolean latestOnly = q.param("latestOnly", Boolean.class);
if (pipeline != null) {
TopLevelItem p = Jenkins.get().getItem(pipeline);
if (latestOnly) {
BlueRun r = getLatestRun((Job) p);
if (r != null) {
return Pageables.wrap(Collections.singletonList(r));
} else {
Pageables.empty();
}
}
if (p instanceof Job) {
return Pageables.wrap(findRuns((Job) p));
} else {
throw new ServiceException.BadRequestException(String.format("Pipeline %s not found", pipeline));
}
} else if (latestOnly) {
return Pageables.empty();
}
return Pageables.wrap(findRuns(null));
}
Aggregations