Refine search
/** * Configure the logging level. */ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE") @RequirePOST public HttpResponse doConfigLogger(@QueryParameter String name, @QueryParameter String level) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); Level lv; if(level.equals("inherit")) lv = null; else lv = Level.parse(level.toUpperCase(Locale.ENGLISH)); Logger.getLogger(name).setLevel(lv); return new HttpRedirect("levels"); }
/** * @deprecated as of 1.317 * Use {@link #doQuietDown()} instead. */ @Deprecated @RequirePOST public synchronized void doQuietDown(StaplerResponse rsp) throws IOException, ServletException { doQuietDown().generateResponse(null, rsp, this); }
/** * Configure the logging level. */ public HttpResponse doConfigLogger(@QueryParameter String name, @QueryParameter String level) { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); Level lv; if(level.equals("inherit")) lv = null; else lv = Level.parse(level.toUpperCase(Locale.ENGLISH)); Logger.getLogger(name).setLevel(lv); return new HttpRedirect("levels"); }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ @RequirePOST public HttpResponse doAct(@QueryParameter String no) throws IOException { if(no!=null) { // dismiss disable(true); // of course the irony is that this redirect won't work return HttpResponses.redirectViaContextPath("/manage"); } else { return new HttpRedirect("https://jenkins.io/redirect/troubleshooting/broken-reverse-proxy"); } }
@RequirePOST public HttpResponse doProxyConfigure(StaplerRequest req) throws IOException, ServletException { Jenkins jenkins = Jenkins.getInstance(); jenkins.checkPermission(CONFIGURE_UPDATECENTER); ProxyConfiguration pc = req.bindJSON(ProxyConfiguration.class, req.getSubmittedForm()); if (pc.name==null) { jenkins.proxy = null; ProxyConfiguration.getXmlFile().delete(); } else { jenkins.proxy = pc; jenkins.proxy.save(); } return new HttpRedirect("advanced"); }
/** * Removes a script from the config and filesystem. * * @param res * response * @param rsp * request * @param name * the name of the file to be removed * @return forward to 'index' * @throws IOException */ public HttpResponse doRemoveScript(StaplerRequest res, StaplerResponse rsp, @QueryParameter("id") String id) throws IOException { checkPermission(Hudson.ADMINISTER); // remove the file File oldScript = new File(getScriptDirectory(), id); oldScript.delete(); try { final GitScriptlerRepository gitRepo = Jenkins.getInstance().getExtensionList(GitScriptlerRepository.class).get(GitScriptlerRepository.class); gitRepo.rmSingleFileToRepo(id); } catch (Exception e) { throw new IOException("failed to update git repo", e); } // remove the meta information ScriptlerConfiguration cfg = getConfiguration(); cfg.removeScript(id); cfg.save(); return new HttpRedirect("index"); }
@RequirePOST public HttpResponse doUpdateSources(StaplerRequest req) throws IOException { Jenkins.getInstance().checkPermission(CONFIGURE_UPDATECENTER); if (req.hasParameter("remove")) { UpdateCenter uc = Jenkins.getInstance().getUpdateCenter(); BulkChange bc = new BulkChange(uc); try { for (String id : req.getParameterValues("sources")) uc.getSites().remove(uc.getById(id)); } finally { bc.commit(); } } else if (req.hasParameter("add")) return new HttpRedirect("addSite"); return new HttpRedirect("./sites"); }
/** * Creates a new log recorder. */ @RequirePOST public HttpResponse doNewLogRecorder(@QueryParameter String name) { Jenkins.checkGoodName(name); logRecorders.put(name,new LogRecorder(name)); // redirect to the config screen return new HttpRedirect(name+"/configure"); }
/** * Saves a script snipplet as file to the system. * * @param req * response * @param rsp * request * @param id * the script id (fileName) * @param name * the name of the script * @param comment * a comment * @param script * script code * @param catalogName * (optional) the name of the catalog the script is loaded/added from * @param originId * (optional) the original id the script had at the catalog * @return forward to 'index' * @throws IOException * @throws ServletException */ public HttpResponse doScriptAdd(StaplerRequest req, StaplerResponse rsp, @QueryParameter("id") String id, @QueryParameter("name") String name, @QueryParameter("comment") String comment, @QueryParameter("script") String script, @QueryParameter("nonAdministerUsing") boolean nonAdministerUsing, @QueryParameter("onlyMaster") boolean onlyMaster, String originCatalogName, String originId) throws IOException, ServletException { checkPermission(Hudson.ADMINISTER); Parameter[] parameters = UIHelper.extractParameters(req.getSubmittedForm()); saveScriptAndForward(id, name, comment, script, nonAdministerUsing, onlyMaster, originCatalogName, originId, parameters); return new HttpRedirect("index"); }
public HttpResponse doTest() { String referer = Stapler.getCurrentRequest().getReferer(); Jenkins j = Jenkins.getInstance(); // May need to send an absolute URL, since handling of HttpRedirect with a relative URL does not currently honor X-Forwarded-Proto/Port at all. String redirect = j.getRootUrl() + "administrativeMonitor/" + id + "/testForReverseProxySetup/" + (referer != null ? Util.rawEncode(referer) : "NO-REFERER") + "/"; LOGGER.log(Level.FINE, "coming from {0} and redirecting to {1}", new Object[] {referer, redirect}); return new HttpRedirect(redirect); }
public HttpResponse doCommenceLogin(StaplerRequest request, @Header("Referer") final String referer) throws IOException { request.getSession().setAttribute(REFERER_ATTRIBUTE,referer); Set<String> scopes = new HashSet<String>(); for (GitHubOAuthScope s : Jenkins.getInstance().getExtensionList(GitHubOAuthScope.class)) { scopes.addAll(s.getScopesToRequest()); } String suffix=""; if (!scopes.isEmpty()) { suffix = "&scope="+Util.join(scopes,","); } return new HttpRedirect(githubUri + "/login/oauth/authorize?client_id=" + clientID + suffix); }
/** * Really deletes the agent. */ @RequirePOST public HttpResponse doDoDelete() throws IOException { checkPermission(DELETE); Node node = getNode(); if (node != null) { Jenkins.getInstance().removeNode(node); } else { AbstractCIBase app = Jenkins.getInstance(); app.removeComputer(this); } return new HttpRedirect(".."); }
/** * Insert or update * @param req * @return */ public HttpResponse doSaveConfig(StaplerRequest req) { checkPermission(Hudson.ADMINISTER); try { JSONObject json = req.getSubmittedForm().getJSONObject("config"); Config config = req.bindJSON(Config.class, json); // potentially replace existing store.save(config); } catch (ServletException e) { e.printStackTrace(); } return new HttpRedirect("index"); }
/** * Delete the slave. * If request have parameter 'deleteMode' than deleting performs in according with this parameter. * @param req StaplerRequest * @return HttpResponse * @throws IOException if any. * @throws ServletException if any. */ public HttpResponse doDeleteWithParam(StaplerRequest req) throws IOException, ServletException { checkPermission(DELETE); String deleteMode = req.getParameter(DELETE_MODE_KEY); if (deleteMode != null) { if (DELETE_MODE_STOP_KEY.equals(deleteMode)) { if (getRunningJobs() != null) { for (AbstractProject job : getRunningJobs()) { Hudson.getInstance().getQueue().cancel(job); } } for (Executor executor : executors) { executor.interrupt(); } } } Hudson.getInstance().removeNode(getNode()); return new HttpRedirect(".."); }
@CLIMethod(name="enable-job") @RequirePOST default HttpResponse doEnable() throws IOException, ServletException { checkPermission(CONFIGURE); makeDisabled(false); return new HttpRedirect("."); }
/** * Cancel previous quiet down Jenkins - preparation for a restart */ @RequirePOST // TODO the cancel link needs to be updated accordingly public synchronized HttpRedirect doCancelQuietDown() { checkPermission(ADMINISTER); isQuietingDown = false; getQueue().scheduleMaintenance(); return new HttpRedirect("."); }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ @RequirePOST public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if (req.hasParameter("no")) { disable(true); return HttpResponses.redirectViaContextPath("/manage"); } else { return new HttpRedirect("manage"); } }
public HttpResponse doUpdateSources(StaplerRequest req) throws IOException { Hudson.getInstance().checkPermission(Hudson.ADMINISTER); if (req.hasParameter("remove")) { UpdateCenter uc = Hudson.getInstance().getUpdateCenter(); BulkChange bc = new BulkChange(uc); try { for (String id : req.getParameterValues("sources")) { uc.getSites().remove(uc.getById(id)); } } finally { bc.commit(); } } else if (req.hasParameter("add")) { return new HttpRedirect("addSite"); } return new HttpRedirect("./sites"); }
/** * Depending on whether the user said "yes" or "no", send him to the right place. */ public HttpResponse doAct(StaplerRequest req, StaplerResponse rsp) throws IOException { if (req.hasParameter("no")) { disable(true); return HttpResponses.redirectViaContextPath("/manage"); } else { return new HttpRedirect("manage"); } }
/** * Uploads a script and stores it with the given filename to the configuration. It will be stored on the filessytem. * * @param req * request * @return forward to index page. * @throws IOException * @throws ServletException */ public HttpResponse doUploadScript(StaplerRequest req) throws IOException, ServletException { checkPermission(Hudson.ADMINISTER); try { FileItem fileItem = req.getFileItem("file"); boolean nonAdministerUsing = req.getSubmittedForm().getBoolean("nonAdministerUsing"); String fileName = Util.getFileName(fileItem.getName()); if (StringUtils.isEmpty(fileName)) { return new HttpRedirect("."); } saveScript(fileItem, nonAdministerUsing, fileName); return new HttpRedirect("index"); } catch (IOException e) { throw e; } catch (Exception e) { throw new ServletException(e); } }