Java Code Examples for org.kohsuke.stapler.StaplerResponse#sendRedirect2()
The following examples show how to use
org.kohsuke.stapler.StaplerResponse#sendRedirect2() .
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: CukedoctorBuildAction.java From cucumber-living-documentation-plugin with MIT License | 6 votes |
public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { File docsPath = getDocsPath(); if (docsPath.getName().endsWith("all.html")) { createAllDocsPage(docsPath); DirectoryBrowserSupport dbs = new DirectoryBrowserSupport(this, new FilePath(getDocsPath()), getTitle(), getUrlName(), false); dbs.generateResponse(req, rsp, this); } else if (docsPath.getName().endsWith("html")) { rsp.sendRedirect2(req.getContextPath()+"/"+build.getUrl() + BASE_URL + "/docsHtml"); } else { rsp.sendRedirect2(req.getContextPath()+"/"+build.getUrl() +BASE_URL + "/docsPdf"); } }
Example 2
Source File: AWSDeviceFarmTestResult.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 6 votes |
/** * Create the graph image for the number of device minutes used in a test run, for the previous three Jenkins runs. * * @param request * @param response * @throws IOException */ @SuppressWarnings("unused") public void doDurationGraph(StaplerRequest request, StaplerResponse response) throws IOException { // Abort if having Java AWT issues. if (ChartUtil.awtProblemCause != null) { response.sendRedirect2(String.format("%s/images/headless.png", request.getContextPath())); return; } // Check the "If-Modified-Since" header and abort if we don't need re-create the graph. if (isCompleted()) { Calendar timestamp = getOwner().getTimestamp(); if (request.checkIfModified(timestamp, response)) { return; } } // Create new duration graph for this AWS Device Farm result. Graph graph = AWSDeviceFarmGraph.createDurationTrendGraph(build, isCompleted(), getPreviousResults(DefaultTrendGraphSize)); graph.doPng(request, response); }
Example 3
Source File: AWSDeviceFarmTestResult.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 6 votes |
/** * Create the graph image for the number of pass/warn/fail results in a test run, for the previous three Jenkins runs. * * @param request * @param response * @throws IOException */ @SuppressWarnings("unused") public void doGraph(StaplerRequest request, StaplerResponse response) throws IOException { // Abort if having Java AWT issues. if (ChartUtil.awtProblemCause != null) { response.sendRedirect2(String.format("%s/images/headless.png", request.getContextPath())); return; } // Check the "If-Modified-Since" header and abort if we don't need re-create the graph. if (isCompleted()) { Calendar timestamp = getOwner().getTimestamp(); if (request.checkIfModified(timestamp, response)) { return; } } // Create new graph for this AWS Device Farm result. Graph graph = AWSDeviceFarmGraph.createResultTrendGraph(build, isCompleted(), getPreviousResults(DefaultTrendGraphSize)); graph.doPng(request, response); }
Example 4
Source File: FingerprintTestUtil.java From docker-traceability-plugin with MIT License | 6 votes |
/** * A stub method, which emulates the submission of the image reference * from the web interface * @param req Incoming request * @param rsp Response * @param imageId image id * @param jobName job name, to which the facet should be attached * @throws IOException Request processing error * @throws ServletException Servlet error */ public static void doTestSubmitBuildRef(StaplerRequest req, StaplerResponse rsp, @QueryParameter(required = true) String imageId, @QueryParameter(required = true) String jobName) throws IOException, ServletException { final Jenkins j = Jenkins.getInstance(); if (j == null) { throw new IOException("Jenkins instance is not active"); } j.checkPermission(Jenkins.ADMINISTER); final AbstractProject item = j.getItem(jobName, j, AbstractProject.class); final Run latest = item != null ? item.getLastBuild() : null; if (latest == null) { throw new IOException("Cannot find a project or run to modify"); } DockerFingerprints.addFromFacet(null,imageId, latest); rsp.sendRedirect2(j.getRootUrl()); }
Example 5
Source File: IssuesDetail.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Returns a new sub page for the selected link. * * @param link * the link to identify the sub page to show * @param request * Stapler request * @param response * Stapler response * * @return the new sub page */ @SuppressWarnings("unused") // Called by jelly view public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) { try { return new DetailFactory().createTrendDetails(link, owner, result, report, newIssues, outstandingIssues, fixedIssues, sourceEncoding, this); } catch (NoSuchElementException ignored) { try { response.sendRedirect2("../"); } catch (IOException ignore) { // ignore } return this; // fallback on broken URLs } }
Example 6
Source File: AWSDeviceFarmProjectAction.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 6 votes |
/** * Return trend graph of all AWS Device Farm results for this project. * * @param request The request object. * @param response The response object. * @throws IOException */ @SuppressWarnings("unused") public void doGraph(StaplerRequest request, StaplerResponse response) throws IOException { // Abort if having Java AWT issues. if (ChartUtil.awtProblemCause != null) { response.sendRedirect2(String.format("%s/images/headless.png", request.getContextPath())); return; } // Get previous AWS Device Farm build and results. AWSDeviceFarmTestResultAction prev = getLastBuildAction(); if (prev == null) { return; } AWSDeviceFarmTestResult result = prev.getResult(); if (result == null) { return; } // Create new graph for the AWS Device Farm results of all runs in this project. Graph graph = AWSDeviceFarmGraph.createResultTrendGraph(prev.getOwner(), false, result.getPreviousResults()); graph.doPng(request, response); }
Example 7
Source File: AWSDeviceFarmProjectAction.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Serve up AWS Device Farm project page which redirects to the latest test results or 404. * * @param request The request object. * @param response The response object. * @throws IOException */ @SuppressWarnings("unused") public void doIndex(StaplerRequest request, StaplerResponse response) throws IOException { AbstractBuild<?, ?> prev = AWSDeviceFarmUtils.previousAWSDeviceFarmBuild(project); if (prev == null) { response.sendRedirect2("404"); } else { // Redirect to build page of most recent AWS Device Farm test run. response.sendRedirect2(String.format("../%d/%s", prev.getNumber(), getUrlName())); } }
Example 8
Source File: DynamicBuild.java From DotCi with MIT License | 5 votes |
@Override @RequirePOST public void doDoDelete(final StaplerRequest req, final StaplerResponse rsp) throws IOException, ServletException { checkPermission(DELETE); this.model.deleteBuild(); rsp.sendRedirect2(req.getContextPath() + '/' + getParent().getUrl()); }
Example 9
Source File: BuildPageRedirectAction.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
public void execute(StaplerResponse response) { if (build != null) { try { response.sendRedirect2(Jenkins.getInstance().getRootUrl() + build.getUrl()); } catch (IOException e) { try { response.sendRedirect2(Jenkins.getInstance().getRootUrl() + build.getBuildStatusUrl()); } catch (IOException e1) { throw HttpResponses.error(500, "Failed to redirect to build page"); } } } }
Example 10
Source File: AbstractTestResultAction.java From junit-plugin with MIT License | 5 votes |
/** * Generates a PNG image for the test result trend. */ public void doGraph( StaplerRequest req, StaplerResponse rsp) throws IOException { if(ChartUtil.awtProblemCause!=null) { // not available. send out error message rsp.sendRedirect2(req.getContextPath()+"/images/headless.png"); return; } if(req.checkIfModified(run.getTimestamp(),rsp)) return; ChartUtil.generateGraph(req,rsp,createChart(req,buildDataSet(req)),calcDefaultSize()); }
Example 11
Source File: DockerTraceabilityRootAction.java From docker-traceability-plugin with MIT License | 5 votes |
/** * Gets an image {@link Fingerprint} page. * @param req Stapler request * @param rsp Stapler response * @param id Image ID. Method supports full 64-char IDs only. * @throws IOException Request processing error * @throws ServletException Servlet error */ public void doImage(StaplerRequest req, StaplerResponse rsp, @QueryParameter(required = true) String id) throws IOException, ServletException { checkPermission(Jenkins.READ); Jenkins j = Jenkins.getInstance(); if (j == null) { rsp.sendError(500, "Jenkins is not ready"); return; } String fingerPrintHash = DockerTraceabilityHelper.getImageHash(id); rsp.sendRedirect2(j.getRootUrl()+"fingerprint/"+fingerPrintHash); }
Example 12
Source File: DockerTraceabilityRootAction.java From docker-traceability-plugin with MIT License | 5 votes |
/** * Gets a container {@link Fingerprint} page. * @param req Stapler request * @param rsp Stapler response * @param id Container ID. Method supports full 64-char IDs only. * @throws IOException Request processing error * @throws ServletException Servlet error */ public void doContainer(StaplerRequest req, StaplerResponse rsp, @QueryParameter(required = true) String id) throws IOException, ServletException { checkPermission(Jenkins.READ); Jenkins j = Jenkins.getInstance(); if (j == null) { rsp.sendError(500, "Jenkins is not ready"); return; } String fingerPrintHash = DockerTraceabilityHelper.getContainerHash(id); rsp.sendRedirect2(j.getRootUrl()+"fingerprint/"+fingerPrintHash); }
Example 13
Source File: AnchoreProjectAction.java From anchore-container-scanner-plugin with Apache License 2.0 | 5 votes |
/** * Redirects the index page to the last report. * * @param request Stapler request * @param response Stapler response * @throws IOException in case of an error */ public void doIndex(final StaplerRequest request, final StaplerResponse response) throws IOException { Run<?, ?> lastRun = this.job.getLastCompletedBuild(); if (lastRun != null) { AnchoreAction a = lastRun.getAction(AnchoreAction.class); if (a != null) response.sendRedirect2(String.format("../%d/%s", lastRun.getNumber(), a.getUrlName())); } }
Example 14
Source File: S3ObjectPath.java From jobcacher-plugin with MIT License | 4 votes |
@Override public HttpResponse browse(StaplerRequest request, StaplerResponse response, Job job, String name) throws IOException { // For now attempt to forward to s3 for browsing response.sendRedirect2("https://console.aws.amazon.com/s3/home?region=" + region + "#&bucket=" + bucketName + "&prefix=" + fullName + "/" + path + "/"); return null; }
Example 15
Source File: NewDotCiJobRepoAction.java From DotCi with MIT License | 4 votes |
public void doCreateProject(StaplerRequest request, StaplerResponse response) throws IOException { DynamicProject project = SetupConfig.get().getDynamicProjectRepository().createNewProject(getGithubRepository(request), getAccessToken(request), getCurrentUserLogin(request)); response.sendRedirect2(redirectAfterCreateItem(request, project)); }
Example 16
Source File: GithubOauthLoginAction.java From DotCi with MIT License | 4 votes |
public void doIndex(StaplerRequest request, StaplerResponse rsp) throws IOException, ServletException, InterruptedException { rsp.sendRedirect2(getSetupConfig().getGithubWebUrl() + "/login/oauth/authorize?client_id=" + getSetupConfig().getGithubClientID() + "&scope=" + getScopes()); }
Example 17
Source File: JobAction.java From warnings-ng-plugin with MIT License | 3 votes |
/** * Redirects the index page to the last result. * * @param request * Stapler request * @param response * Stapler response * * @throws IOException * in case of an error */ @SuppressWarnings("unused") // Called by jelly view public void doIndex(final StaplerRequest request, final StaplerResponse response) throws IOException { Optional<ResultAction> action = getLatestAction(); if (action.isPresent()) { response.sendRedirect2(String.format("../%d/%s", action.get().getOwner().getNumber(), labelProvider.getId())); } }