Search in sources :

Example 16 with TopLevelItem

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));
}
Also used : BlueRun(io.jenkins.blueocean.rest.model.BlueRun) TopLevelItem(hudson.model.TopLevelItem) Job(hudson.model.Job)

Aggregations

TopLevelItem (hudson.model.TopLevelItem)16 Test (org.junit.Test)5 File (java.io.File)3 IOException (java.io.IOException)3 Map (java.util.Map)3 OrganizationFolder (jenkins.branch.OrganizationFolder)3 Jenkins (jenkins.model.Jenkins)3 WorkflowMultiBranchProject (org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject)3 Domain (com.cloudbees.plugins.credentials.domains.Domain)2 Cause (hudson.model.Cause)2 FreeStyleBuild (hudson.model.FreeStyleBuild)2 FreeStyleProject (hudson.model.FreeStyleProject)2 Hudson (hudson.model.Hudson)2 Item (hudson.model.Item)2 User (hudson.model.User)2 ErrorMessage (io.jenkins.blueocean.commons.ErrorMessage)2 ServiceException (io.jenkins.blueocean.commons.ServiceException)2 BlueOceanCredentialsProvider (io.jenkins.blueocean.rest.impl.pipeline.credential.BlueOceanCredentialsProvider)2 BlueOceanDomainRequirement (io.jenkins.blueocean.rest.impl.pipeline.credential.BlueOceanDomainRequirement)2 ConfiguredWithCode (org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)2