Skip to content

Commit

Permalink
[FIXED JENKINS-47139] Do not set Jenkins.version too early in startup…
Browse files Browse the repository at this point in the history
…, lest InstallUtil.getLastExecVersion get confused.
  • Loading branch information
jglick committed Sep 27, 2017
1 parent 34a8778 commit 0792342
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/src/main/java/jenkins/install/InstallUtil.java
Expand Up @@ -54,6 +54,7 @@
import hudson.model.UpdateCenter.InstallationJob;
import hudson.model.UpdateCenter.UpdateCenterJob;
import hudson.util.VersionNumber;
import java.util.logging.Level;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import jenkins.util.xml.XMLUtils;
Expand Down Expand Up @@ -256,6 +257,7 @@ public static void saveLastExecVersion() {
try {
String lastVersion = XMLUtils.getValue("/hudson/version", configFile);
if (lastVersion.length() > 0) {
LOGGER.log(Level.FINE, "discovered serialized lastVersion {0}", lastVersion);
return lastVersion;
}
} catch (Exception e) {
Expand Down
8 changes: 7 additions & 1 deletion core/src/main/java/jenkins/model/Jenkins.java
Expand Up @@ -3191,7 +3191,13 @@ public void run(Reactor session) throws Exception {
*/
public synchronized void save() throws IOException {
if(BulkChange.contains(this)) return;
version = VERSION;

if (initLevel == InitMilestone.COMPLETED) {
LOGGER.log(FINE, "setting version {0} to {1}", new Object[] {version, VERSION});
version = VERSION;
} else {
LOGGER.log(FINE, "refusing to set version {0} to {1} during {2}", new Object[] {version, VERSION, initLevel});
}

getConfigFile().write(this);
SaveableListener.fireOnChange(this, getConfigFile());
Expand Down

0 comments on commit 0792342

Please sign in to comment.