提交 4376fded 编写于 作者: K Keith Zantow 提交者: Oleg Nenashev

[JENKINS-37438] - method to run setup wizard after Jenkins is modified (#2512)

上级 67347c3c
......@@ -40,6 +40,7 @@ import javax.annotation.Nonnull;
import javax.inject.Provider;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
......@@ -69,6 +70,7 @@ public class InstallUtil {
// tests need this to be 1.0
private static final VersionNumber NEW_INSTALL_VERSION = new VersionNumber("1.0");
private static final VersionNumber FORCE_NEW_INSTALL_VERSION = new VersionNumber("0.0");
/**
* Simple chain pattern using iterator.next()
......@@ -166,7 +168,7 @@ public class InstallUtil {
// Neither the top level config or the lastExecVersionFile have a version
// stored in them, which means it's a new install.
if (lastRunVersion.compareTo(NEW_INSTALL_VERSION) == 0) {
if (FORCE_NEW_INSTALL_VERSION.equals(lastRunVersion) || lastRunVersion.compareTo(NEW_INSTALL_VERSION) == 0) {
Jenkins j = Jenkins.getInstance();
// Allow for skipping
......@@ -181,11 +183,13 @@ public class InstallUtil {
}
}
// Edge case: used Jenkins 1 but did not save the system config page,
// the version is not persisted and returns 1.0, so try to check if
// they actually did anything
if (!j.getItemMap().isEmpty() || !j.getNodes().isEmpty()) {
return InstallState.UPGRADE;
if (!FORCE_NEW_INSTALL_VERSION.equals(lastRunVersion)) {
// Edge case: used Jenkins 1 but did not save the system config page,
// the version is not persisted and returns 1.0, so try to check if
// they actually did anything
if (!j.getItemMap().isEmpty() || !j.getNodes().isEmpty()) {
return InstallState.UPGRADE;
}
}
return InstallState.INITIAL_SECURITY_SETUP;
......@@ -227,7 +231,13 @@ public class InstallUtil {
File lastExecVersionFile = getLastExecVersionFile();
if (lastExecVersionFile.exists()) {
try {
return FileUtils.readFileToString(lastExecVersionFile);
String version = FileUtils.readFileToString(lastExecVersionFile);
// JENKINS-37438 blank will force the setup
// wizard regardless of current state of the system
if (StringUtils.isBlank(version)) {
return FORCE_NEW_INSTALL_VERSION.toString();
}
return version;
} catch (IOException e) {
LOGGER.log(SEVERE, "Unexpected Error. Unable to read " + lastExecVersionFile.getAbsolutePath(), e);
LOGGER.log(WARNING, "Unable to determine the last running version (see error above). Treating this as a restart. No plugins will be updated.");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册