public synchronized void run() { if (!(status instanceof Pending)) { return; } status = new Running(); try { // safeRestart records the current authentication for the log, so set it to the managing user try (ACLContext acl = ACL.as(User.get(authentication, false, Collections.emptyMap()))) { Jenkins.getInstance().safeRestart(); } } catch (RestartNotSupportedException exception) { // ignore if restart is not allowed status = new Failure(); error = exception; } }
/** * Queues up a restart of Jenkins for when there are no builds running, if we can. * * This first replaces "app" to {@link HudsonIsRestarting} * * @since 1.332 */ @CLIMethod(name="safe-restart") public HttpResponse doSafeRestart(StaplerRequest req) throws IOException, ServletException, RestartNotSupportedException { checkPermission(ADMINISTER); if (req != null && req.getMethod().equals("GET")) return HttpResponses.forwardToView(this,"_safeRestart.jelly"); if (req == null || req.getMethod().equals("POST")) { safeRestart(); } return HttpResponses.redirectToDot(); }
@Override protected int run() throws Exception { Jenkins jenkins = Jenkins.get(); jenkins.checkPermission(Jenkins.ADMINISTER); PluginManager manager = jenkins.getPluginManager(); boolean enabledAnyPlugins = false; for (String pluginName : pluginNames) { enabledAnyPlugins |= enablePlugin(manager, pluginName); } if (restart && enabledAnyPlugins) { jenkins.safeRestart(); } return 0; }
/** * Restart if this particular result of the disablement of a plugin and its dependant plugins (depending on the * strategy used) has a plugin disablexd. * @param oneResult the result of a plugin (and its dependants). * @return true if it end up in restarting jenkins. */ private boolean restartIfNecessary(PluginWrapper.PluginDisableResult oneResult) throws RestartNotSupportedException { PluginWrapper.PluginDisableStatus status = oneResult.getStatus(); if (PluginWrapper.PluginDisableStatus.DISABLED.equals(status)) { Jenkins.get().safeRestart(); return true; } if (oneResult.getDependantsDisableStatus().size() > 0) { for (PluginWrapper.PluginDisableResult oneDependantResult : oneResult.getDependantsDisableStatus()) { if (restartIfNecessary(oneDependantResult)) { return true; } } } return false; }
h.safeRestart(); return 0; // all success
/** * Queues up a restart of Jenkins for when there are no builds running, if we can. * * This first replaces "app" to {@link HudsonIsRestarting} * * @since 1.332 */ @CLIMethod(name="safe-restart") public HttpResponse doSafeRestart(StaplerRequest req) throws IOException, ServletException, RestartNotSupportedException { checkPermission(ADMINISTER); if (req != null && req.getMethod().equals("GET")) return HttpResponses.forwardToView(this,"_safeRestart.jelly"); if (req == null || req.getMethod().equals("POST")) { safeRestart(); } return HttpResponses.redirectToDot(); }
public synchronized void run() { if (!(status instanceof Pending)) { return; } status = new Running(); try { // safeRestart records the current authentication for the log, so set it to the managing user try (ACLContext _ = ACL.as(User.get(authentication, false, Collections.emptyMap()))) { Jenkins.getInstance().safeRestart(); } } catch (RestartNotSupportedException exception) { // ignore if restart is not allowed status = new Failure(); error = exception; } }
h.safeRestart(); return 0; // all success