org.kohsuke.stapler.Ancestor Java Examples

The following examples show how to use org.kohsuke.stapler.Ancestor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamicSubBuild.java    From DotCi with MIT License 6 votes vote down vote up
@Override
public String getUpUrl() {
    final StaplerRequest req = Stapler.getCurrentRequest();
    if (req != null) {
        final List<Ancestor> ancs = req.getAncestors();
        for (int i = 1; i < ancs.size(); i++) {
            if (ancs.get(i).getObject() == this) {
                final Object parentObj = ancs.get(i - 1).getObject();
                if (parentObj instanceof DynamicBuild || parentObj instanceof DynamicSubProject) {
                    return ancs.get(i - 1).getUrl() + '/';
                }
            }
        }
    }
    return super.getDisplayName();
}
 
Example #2
Source File: ScmContainer.java    From blueocean-plugin with MIT License 5 votes vote down vote up
public ScmContainer() {
    Ancestor ancestor = Stapler.getCurrentRequest().findAncestor(BlueOrganization.class);
    BlueOrganization organization = null;
    if(ancestor != null){
        organization = (BlueOrganization) ancestor.getObject();
    }
    this.self = (organization != null) ? organization.getLink().rel("scm")
            : new Link("/organizations/jenkins/scm/");
}
 
Example #3
Source File: GitLabPushTrigger.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private Job<?, ?> retrieveCurrentJob() {
    StaplerRequest request = Stapler.getCurrentRequest();
    if (request != null) {
        Ancestor ancestor = request.findAncestor(Job.class);
        return ancestor == null ? null : (Job<?, ?>) ancestor.getObject();
    }
    return null;
}
 
Example #4
Source File: RelativeLocation.java    From jenkins-build-monitor-plugin with MIT License 5 votes vote down vote up
public String name() {
    ItemGroup ig = null;

    StaplerRequest request = Stapler.getCurrentRequest();
    for( Ancestor a : request.getAncestors() ) {
        if(a.getObject() instanceof BuildMonitorView) {
            ig = ((View) a.getObject()).getOwnerItemGroup();
        }
    }

    return Functions.getRelativeDisplayNameFrom(job, ig);
}
 
Example #5
Source File: ProjectUtils.java    From ez-templates with Apache License 2.0 5 votes vote down vote up
public static AbstractProject findProject(StaplerRequest request) {
    Ancestor ancestor = request.getAncestors().get(request.getAncestors().size() - 1);
    while (ancestor != null && !(ancestor.getObject() instanceof AbstractProject)) {
        ancestor = ancestor.getPrev();
    }
    if (ancestor == null) {
        return null;
    }
    return (AbstractProject) ancestor.getObject();
}
 
Example #6
Source File: Computers.java    From blueocean-plugin with MIT License 4 votes vote down vote up
private static BlueOrganization getOrganization() {
    // This should always have an organization as a parent, as it's an OrganizationRoute
    Ancestor ancestor = Stapler.getCurrentRequest().findAncestor(BlueOrganization.class);
    BlueOrganization organization = (BlueOrganization)ancestor.getObject();
    return organization;
}
 
Example #7
Source File: ParameterizedStaplerRequest.java    From parameterized-scheduler with MIT License 4 votes vote down vote up
@Override
public List<Ancestor> getAncestors() {
	return null;
}
 
Example #8
Source File: ParameterizedStaplerRequest.java    From parameterized-scheduler with MIT License 4 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public Ancestor findAncestor(Class type) {
	return null;
}
 
Example #9
Source File: ParameterizedStaplerRequest.java    From parameterized-scheduler with MIT License 4 votes vote down vote up
@Override
public Ancestor findAncestor(Object o) {
	return null;
}