Search in sources :

Example 1 with BlueMultiBranchPipeline

use of io.jenkins.blueocean.rest.model.BlueMultiBranchPipeline in project blueocean-plugin by jenkinsci.

the class BlueOceanUrlMapperImpl method getUrl.

@Override
public String getUrl(@Nonnull ModelObject modelObject) {
    BlueOrganization organization = getOrganization(modelObject);
    if (organization == null) {
        // no organization, best we can do is to land user on landing page
        return getLandingPagePath();
    }
    String organizationName = organization.getName();
    String baseUrl = getOrgPrefix(organizationName);
    if (modelObject instanceof ModifiableTopLevelItemGroup) {
        return baseUrl;
    } else if (modelObject instanceof Job) {
        BluePipeline blueResource = getJobResource(modelObject);
        if (blueResource != null) {
            return getPipelineUrl(baseUrl, blueResource);
        }
    } else if (modelObject instanceof Run) {
        Run run = (Run) modelObject;
        Job job = run.getParent();
        BluePipeline blueResource = getJobResource(job);
        if (blueResource != null) {
            // encoded and re-encode to do the full monty. Nasty :)
            return baseUrl + "/" + encodeURIComponent(blueResource.getFullName()) + "/detail/" + encodeURIComponent(decodeURIComponent(job.getName())) + "/" + encodeURIComponent(run.getId());
        }
    } else if (modelObject instanceof Item) {
        Resource bluePipeline = BluePipelineFactory.resolve((Item) modelObject);
        if (bluePipeline instanceof BlueMultiBranchPipeline) {
            return getPipelineUrl(baseUrl, (BluePipeline) bluePipeline);
        }
    }
    return null;
}
Also used : Item(hudson.model.Item) ModifiableTopLevelItemGroup(jenkins.model.ModifiableTopLevelItemGroup) BlueOrganization(io.jenkins.blueocean.rest.model.BlueOrganization) Resource(io.jenkins.blueocean.rest.model.Resource) BluePipeline(io.jenkins.blueocean.rest.model.BluePipeline) Run(hudson.model.Run) Job(hudson.model.Job) BlueMultiBranchPipeline(io.jenkins.blueocean.rest.model.BlueMultiBranchPipeline)

Aggregations

Item (hudson.model.Item)1 Job (hudson.model.Job)1 Run (hudson.model.Run)1 BlueMultiBranchPipeline (io.jenkins.blueocean.rest.model.BlueMultiBranchPipeline)1 BlueOrganization (io.jenkins.blueocean.rest.model.BlueOrganization)1 BluePipeline (io.jenkins.blueocean.rest.model.BluePipeline)1 Resource (io.jenkins.blueocean.rest.model.Resource)1 ModifiableTopLevelItemGroup (jenkins.model.ModifiableTopLevelItemGroup)1