提交 273287aa 编写于 作者: K Kohsuke Kawaguchi

exposed whether a restart is needed

上级 62a23114
......@@ -113,7 +113,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
private static final String UPDATE_CENTER_URL = System.getProperty(UpdateCenter.class.getName()+".updateCenterUrl","http://updates.jenkins-ci.org/");
/**
* {@link #getId} of the default update site.
* {@linkplain UpdateSite#getId() ID} of the default update site.
* @since 1.483
*/
public static final String ID_DEFAULT = "default";
......@@ -151,10 +151,27 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
*/
private UpdateCenterConfiguration config;
private boolean requiresRestart;
public UpdateCenter() {
configure(new UpdateCenterConfiguration());
}
/**
* If any of the executed {@link UpdateCenterJob}s requires a restart
* to take effect, this method returns true.
*
* <p>
* This doesn't necessarily mean the user has scheduled or initiated
* the restart operation.
*
* @see #isRestartScheduled()
*/
@Exported
public boolean isRestartRequiredForCompletion() {
return requiresRestart;
}
public Api getApi() {
return new Api(this);
}
......@@ -384,8 +401,10 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
}
/**
* Checks if restart is scheduled
*
* Checks if the restart operation is scheduled
* (which means in near future Jenkins will restart by itself)
*
* @see #isRestartRequiredForCompletion()
*/
public boolean isRestartScheduled() {
for (UpdateCenterJob job : getJobs()) {
......@@ -1042,6 +1061,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
} catch (InstallationStatus e) {
status = e;
if (status.isSuccess()) onSuccess();
requiresRestart |= status.requiresRestart();
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Failed to install "+getName(),e);
status = new Failure(e);
......@@ -1091,6 +1111,13 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
public final String getType() {
return getClass().getSimpleName();
}
/**
* Indicates that a restart is needed to complete the tasks.
*/
public boolean requiresRestart() {
return false;
}
}
/**
......@@ -1123,6 +1150,11 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
public String getMessage() {
return message.toString();
}
@Override
public boolean requiresRestart() {
return true;
}
}
/**
......
......@@ -673,6 +673,7 @@ public class UpdateSite {
* @param dynamicLoad
* If true, the plugin will be dynamically loaded into this Jenkins. If false,
* the plugin will only take effect after the reboot.
* See {@link UpdateCenter#isRestartRequiredForCompletion()}
*/
public Future<UpdateCenterJob> deploy(boolean dynamicLoad) {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册