/** * Exposes this failure to UI and invoke the hook. * * @param home * JENKINS_HOME if it's already known. */ public void publish(ServletContext context, @CheckForNull File home) { LOGGER.log(Level.SEVERE, "Failed to initialize Jenkins",this); WebApp.get(context).setApp(this); if (home == null) { return; } new GroovyHookScript("boot-failure", context, home, BootFailure.class.getClassLoader()) .bind("exception",this) .bind("home",home) .bind("servletContext", context) .bind("attempts",loadAttempts(home)) .run(); }
/** * Reloads the configuration synchronously. * Beware that this calls neither {@link ItemListener#onLoaded} nor {@link Initializer}s. */ public void reload() throws IOException, InterruptedException, ReactorException { queue.save(); executeReactor(null, loadTasks()); // Ensure we reached the final initialization state. Log the error otherwise if (initLevel != InitMilestone.COMPLETED) { LOGGER.log(SEVERE, "Jenkins initialization has not reached the COMPLETED initialization milestone after the configuration reload. " + "Current state: {0}. " + "It may cause undefined incorrect behavior in Jenkins plugin relying on this state. " + "It is likely an issue with the Initialization task graph. " + "Example: usage of @Initializer(after = InitMilestone.COMPLETED) in a plugin (JENKINS-37759). " + "Please create a bug in Jenkins bugtracker.", initLevel); } User.reload(); queue.load(); WebApp.get(servletContext).setApp(this); }
/** * Reloads the configuration. */ @RequirePOST public synchronized HttpResponse doReload() throws IOException { checkPermission(ADMINISTER); LOGGER.log(Level.WARNING, "Reloading Jenkins as requested by {0}", getAuthentication().getName()); // engage "loading ..." UI and then run the actual task in a separate thread WebApp.get(servletContext).setApp(new HudsonIsLoading()); new Thread("Jenkins config reload thread") { @Override public void run() { try { ACL.impersonate(ACL.SYSTEM); reload(); } catch (Exception e) { LOGGER.log(SEVERE,"Failed to reload Jenkins config",e); new JenkinsReloadFailed(e).publish(servletContext,root); } } }.start(); return HttpResponses.redirectViaContextPath("/"); }
/** * @param app * The app object that handles the root of the URL. */ public JettyRunner(Object app) { server = new Server(); ServletContextHandler root = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); root.addServlet(new ServletHolder(new Stapler()), "/*"); WebApp.get(root.getServletContext()).setApp(app); }
/** * Exposes this failure to UI and invoke the hook. * * @param home * JENKINS_HOME if it's already known. */ public void publish(ServletContext context, @CheckForNull File home) { LOGGER.log(Level.SEVERE, "Failed to initialize Jenkins",this); WebApp.get(context).setApp(this); if (home == null) { return; } new GroovyHookScript("boot-failure", context, home, BootFailure.class.getClassLoader()) .bind("exception",this) .bind("home",home) .bind("servletContext", context) .bind("attempts",loadAttempts(home)) .run(); }
/** * Reloads the configuration synchronously. * Beware that this calls neither {@link ItemListener#onLoaded} nor {@link Initializer}s. */ public void reload() throws IOException, InterruptedException, ReactorException { queue.save(); executeReactor(null, loadTasks()); // Ensure we reached the final initialization state. Log the error otherwise if (initLevel != InitMilestone.COMPLETED) { LOGGER.log(SEVERE, "Jenkins initialization has not reached the COMPLETED initialization milestone after the configuration reload. " + "Current state: {0}. " + "It may cause undefined incorrect behavior in Jenkins plugin relying on this state. " + "It is likely an issue with the Initialization task graph. " + "Example: usage of @Initializer(after = InitMilestone.COMPLETED) in a plugin (JENKINS-37759). " + "Please create a bug in Jenkins bugtracker.", initLevel); } User.reload(); queue.load(); WebApp.get(servletContext).setApp(this); }
/** * Reloads the configuration. */ @RequirePOST public synchronized HttpResponse doReload() throws IOException { checkPermission(ADMINISTER); LOGGER.log(Level.WARNING, "Reloading Jenkins as requested by {0}", getAuthentication().getName()); // engage "loading ..." UI and then run the actual task in a separate thread WebApp.get(servletContext).setApp(new HudsonIsLoading()); new Thread("Jenkins config reload thread") { @Override public void run() { try { ACL.impersonate(ACL.SYSTEM); reload(); } catch (Exception e) { LOGGER.log(SEVERE,"Failed to reload Jenkins config",e); new JenkinsReloadFailed(e).publish(servletContext,root); } } }.start(); return HttpResponses.redirectViaContextPath("/"); }
@Override protected void setUp() throws Exception { super.setUp(); server = new Server(); server.setHandler(new WebAppContext("/noroot", "")); final Context context = new Context(server, getContextPath(), Context.SESSIONS); configure(context); server.setHandler(context); SocketConnector connector = new SocketConnector(); server.addConnector(connector); server.start(); url = new URL("http://localhost:"+connector.getLocalPort()+getContextPath()+"/"); servletContext = context.getServletContext(); webApp = WebApp.get(servletContext); // export the test object as the root as a reasonable default. webApp.setApp(this); }