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;
}
Aggregations