@StaplerDispatchable public void getTestForReverseProxySetup(String rest) { Jenkins j = Jenkins.getInstance(); String inferred = j.getRootUrlFromRequest() + "manage"; // TODO this could also verify that j.getRootUrl() has been properly configured, and send a different message if not if (rest.startsWith(inferred)) { // not using equals due to JENKINS-24014 throw HttpResponses.ok(); } else { LOGGER.log(Level.WARNING, "{0} vs. {1}", new Object[] {inferred, rest}); throw HttpResponses.errorWithoutStack(404, inferred + " vs. " + rest); } }
return getRootUrlFromRequest(); return null;
public PageMatcher getPageMatcherMatching(String url){ String rootUrl = Jenkins.getInstance().getRootUrlFromRequest(); String cleanedUrl = null; if(url.startsWith(rootUrl)){ cleanedUrl = url.substring(rootUrl.length()); } else { cleanedUrl = url; } for(PageMatcher pm : pageMatchers){ if(pm.getUrlRegex().matcher(cleanedUrl).matches()){ return pm; } } return null; }
/** * Exposes our URL (as we will be invoked from an unknown page so we need an absolute URL). * * @return our URL. */ public String getUrl() { return String.format( "%sdescriptor/%s/resolver/%s/provider/%s/context/%s", Jenkins.getActiveInstance().getRootUrlFromRequest(), CredentialsSelectHelper.class.getName(), Util.rawEncode(resolver.getClass().getName()), Util.rawEncode(provider.getClass().getName()), Util.rawEncode(token) ); }
public void getTestForReverseProxySetup(String rest) { Jenkins j = Jenkins.getInstance(); String inferred = j.getRootUrlFromRequest() + "manage"; // TODO this could also verify that j.getRootUrl() has been properly configured, and send a different message if not if (rest.startsWith(inferred)) { // not using equals due to JENKINS-24014 throw HttpResponses.ok(); } else { LOGGER.log(Level.WARNING, "{0} vs. {1}", new Object[] {inferred, rest}); throw HttpResponses.errorWithoutStack(404, inferred + " vs. " + rest); } }
/** * Exposes our URL (as we will be invoked from an unknown page so we need an absolute URL). * * @return our URL. */ public String getUrl() { return String.format( "%sdescriptor/%s/resolver/%s/provider/%s/context/%s", Jenkins.getActiveInstance().getRootUrlFromRequest(), CredentialsSelectHelper.class.getName(), Util.rawEncode(resolver.getClass().getName()), Util.rawEncode(provider.getClass().getName()), Util.rawEncode(token) ); }
public void doLeaveCreationResult() { //Redirect back to the central managment page try { Jenkins j = Jenkins.getInstance(); String rootURL = j.getRootUrlFromRequest(); StaplerResponse rsp = Stapler.getCurrentResponse(); rsp.sendRedirect(rootURL + "/manage"); } catch (IOException ex) { //Ignore } catch (NullPointerException ex) { //Ignore } }
/** * Gets the check id url for the specified store. * * @param store the store. * @return the url of the id check endpoint. * @throws UnsupportedEncodingException if the JVM does not implement the JLS. */ public String getCheckIdUrl(CredentialsStore store) throws UnsupportedEncodingException { ModelObject context = store.getContext(); for (ContextResolver r : ExtensionList.lookup(ContextResolver.class)) { String token = r.getToken(context); if (token != null) { return Jenkins.getActiveInstance().getRootUrlFromRequest() + "/" + getDescriptorUrl() + "/checkId?provider=" + r.getClass().getName() + "&token=" + URLEncoder.encode(token, "UTF-8"); } } return Jenkins.getActiveInstance().getRootUrlFromRequest() + "/" + getDescriptorUrl() + "/checkId?provider=null&token=null"; }
public void doLeaveCreationResult() { //Redirect back to the central management page try { Jenkins j = Jenkins.getInstance(); String rootURL = j.getRootUrlFromRequest(); StaplerResponse rsp = Stapler.getCurrentResponse(); rsp.sendRedirect(rootURL + "/manage"); } catch (IOException ex) { //Ignore } catch (NullPointerException ex) { //Ignore } }
/** * Gets the check id url for the specified store. * * @param store the store. * @return the url of the id check endpoint. * @throws UnsupportedEncodingException if the JVM does not implement the JLS. */ public String getCheckIdUrl(CredentialsStore store) throws UnsupportedEncodingException { ModelObject context = store.getContext(); for (ContextResolver r : ExtensionList.lookup(ContextResolver.class)) { String token = r.getToken(context); if (token != null) { return Jenkins.getActiveInstance().getRootUrlFromRequest() + "/" + getDescriptorUrl() + "/checkId?provider=" + r.getClass().getName() + "&token=" + URLEncoder.encode(token, "UTF-8"); } } return Jenkins.getActiveInstance().getRootUrlFromRequest() + "/" + getDescriptorUrl() + "/checkId?provider=null&token=null"; }
return getRootUrlFromRequest(); return null;
/** * This starts the job creation and redirects the user to the result page. * <p> * <b>Do NOT call this directly</b>, if not triggered by the user. Instead * call {@link #triggerCreateProjects()}. */ public void doCreateProjects() { //Trigger the project creation this.lastCreationState = this.triggerCreateProjects(); Jenkins j = Jenkins.getInstance(); String rootURL = j.getRootUrlFromRequest(); //Redirect to the status page for job creation try { StaplerResponse rsp = Stapler.getCurrentResponse(); rsp.sendRedirect(rootURL + "/project_creation/showCreationResults"); } catch (IOException ex) { //Ignore } catch (NullPointerException ex) { //Ignore } }
/** * This starts the job creation and redirects the user to the result page. * <p> * <b>Do NOT call this directly</b>, if not triggered by the user. Instead * call {@link #triggerCreateProjects()}. */ public void doCreateProjects() { //Trigger the project creation this.lastCreationState = this.triggerCreateProjects(); Jenkins j = Jenkins.getInstance(); String rootURL = j.getRootUrlFromRequest(); //Redirect to the status page for job creation try { StaplerResponse rsp = Stapler.getCurrentResponse(); rsp.sendRedirect(rootURL + "/project_creation/showCreationResults"); } catch (IOException ex) { //Ignore } catch (NullPointerException ex) { //Ignore } }
private void generateUrl() { Run<?,?> build = o.getRun(); String buildLink = build.getUrl(); String actionUrl = o.getTestResultAction().getUrlName(); this.url = Jenkins.getActiveInstance().getRootUrlFromRequest() + buildLink + actionUrl + o.getUrl(); }