Package org.kohsuke.stapler

Examples of org.kohsuke.stapler.StaplerRequest


        return super.getUpUrl();
    }

    @Override
    public String getDisplayName() {
        StaplerRequest req = Stapler.getCurrentRequest();
        if(req!=null) {
            List<Ancestor> ancs = req.getAncestors();
            for( int i=1; i<ancs.size(); i++) {
                if(ancs.get(i).getObject()==this) {
                    if(ancs.get(i-1).getObject() instanceof MavenModuleSetBuild) {
                        // if under MavenModuleSetBuild, display the module name
                        return getParent().getDisplayName();
View Full Code Here


        verifyBuildTrigger(request);
    }

    @Test
    public void should_trigger_builds_for_payload() throws IOException, InterruptedException {
        StaplerRequest request = mock(StaplerRequest.class);
        when(request.getParameter("payload")).thenReturn("payload");
        verifyBuildTrigger(request);
    }
View Full Code Here

        githubWebhook.doIndex(mock(StaplerRequest.class), null);
    }

    @Test
    public void should_get_payload_from_post_if_post() throws IOException, InterruptedException {
        StaplerRequest request = mock(StaplerRequest.class);
        when(request.getParameter("payload")).thenReturn(null);
        when(request.getMethod()).thenReturn("POST");
        doReturn("payload").when(githubWebhook).getRequestPayload(request);
        verifyBuildTrigger(request);
    }
View Full Code Here

    protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
        // noop
    }

    public String getViewType() {
        StaplerRequest currentRequest = Stapler.getCurrentRequest();
        String viewType = (String) currentRequest.getSession().getAttribute("viewType");
        return viewType == null ? "builds" : viewType;
    }
View Full Code Here

        return dynamicBuildRepository.<B> getLastBuild(this);
    }
    @Override
    public B getLastBuild() {
        String branch = "master";
        StaplerRequest currentRequest = Stapler.getCurrentRequest();
        if (currentRequest != null && StringUtils.isNotEmpty(currentRequest.getParameter("branch"))) {
            branch = currentRequest.getParameter("branch");
        }
        return dynamicBuildRepository.<B> getLastBuild(this,branch);
    }
View Full Code Here

        }
    }

    @Override
    public String getUpUrl() {
        StaplerRequest req = Stapler.getCurrentRequest();
        if (req != null) {
            List<Ancestor> ancs = req.getAncestors();
            for (int i = 1; i < ancs.size(); i++) {
                if (ancs.get(i).getObject() == this) {
                    Object parentObj = ancs.get(i - 1).getObject();
                    if (parentObj instanceof DynamicBuild || parentObj instanceof DynamicSubProject) {
                        return ancs.get(i - 1).getUrl() + '/';
View Full Code Here

        return Collections.emptyList();
    }

    @Override
    public Object getTarget() {
        StaplerRequest currentRequest = Stapler.getCurrentRequest();
        //@formatter:off
        if (!currentRequest.getRequestURI().matches(".*(api/(json|xml)).*")
            && !currentRequest.getRequestURI().contains("buildWithParameters")
            && !currentRequest.getRequestURI().contains("artifact")) {
        //@formatter:on
            AuthenticationService.authenticate();
        }

        return this;
View Full Code Here

    @Test
    @PrepareForTest(Stapler.class)
    public void testGetActionUrl_absolutePath() throws Exception{
        String contextPath = "/jenkins";
        StaplerRequest req = createMockRequest(contextPath);
        String[] paths = {
            "/",
            "/foo/bar",
        };
        mockStatic(Stapler.class);
View Full Code Here

    @Test
    @PrepareForTest(Stapler.class)
    public void testGetActionUrl_relativePath() throws Exception{
        String contextPath = "/jenkins";
        String itUrl = "iturl/";
        StaplerRequest req = createMockRequest(contextPath);
        String[] paths = {
            "foo/bar",
            "./foo/bar",
            "../foo/bar",
        };
View Full Code Here

        when(action.getUrlName()).thenReturn(uri);
        return action;
    }

    private static StaplerRequest createMockRequest(String contextPath) {
        StaplerRequest req = mock(StaplerRequest.class);
        when(req.getContextPath()).thenReturn(contextPath);
        return req;
    }
View Full Code Here

TOP

Related Classes of org.kohsuke.stapler.StaplerRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.