mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-30 21:15:23 +00:00
Added downgrade support for the core and plugins.
-------- Merged revisions 32975,33588,33697,34342 via svnmerge from https://www.dev.java.net/svn/hudson/branches/downgrade ........ r32975 | kohsuke | 2010-07-16 21:27:59 +0200 (Fri, 16 Jul 2010) | 1 line committed my partially modified version ........ r33588 | dienomight | 2010-08-05 09:42:36 +0200 (Thu, 05 Aug 2010) | 13 lines Added getBackupVersion (UpdateCenter) downgrade button now shows version of backup war file Added HudsonDowngradeJob (UpdateCenter) downgrading process is works now as HudsonUpgradeJob Changed rewriteHudsonWar (Lifecycle) backup file is deleted when downgrading hudson/model/Hudson/downgrade_success.jelly is no longer necessary Changed rewriteHudsonWar(WindowsServiceLifecycle) hudson run as windows service creates backup during upgrading ........ r33697 | dienomight | 2010-08-11 17:09:48 +0200 (Wed, 11 Aug 2010) | 8 lines committed changes: "plugins downgrade functionality" added: * PluginDowngradeJob in UpdateCenter * getCanDowngrade & getBackupPath & getBackupVersion in PluginWrapper * additional "previous version" column in installed.jelly (PluginManager) with downgrade button (when it's possible to downgrade) * doDowngrade in PluginManager * deployBackup in UpdateSite ........ r34342 | dienomight | 2010-09-03 09:52:13 +0200 (Fri, 03 Sep 2010) | 12 lines Code improvements: jelly files: *I put text inside ${%} so it would be available for translation. UpdateCenter: *changed getCanDowngrade to isDowngradable *getBackupVersion use JarFile class to get version of .war backup PluginWrapper: *changed getBackupPath to getBackupFile *getBackupVersion use JarFile class to get version of plugin backup PluginManager: *changed condition in doDowngrade method ........ git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@34543 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
cba29b60aa
commit
8ec3054c30
11 files changed
+292
-2
No files matched your search
@@ -37,7 +37,6 @@ import java.io.OutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.logging.Logger;
|
||||
@@ -47,6 +46,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
/**
|
||||
* Represents a Hudson plug-in and associated control information
|
||||
* for Hudson to control {@link Plugin}.
|
||||
@@ -464,6 +466,37 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
|
||||
return shortName.compareToIgnoreCase(pw.shortName);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if backup of previous version of plugin exists
|
||||
*/
|
||||
public boolean isDowngradable() {
|
||||
return getBackupFile().exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Where is the backup file?
|
||||
*/
|
||||
public File getBackupFile() {
|
||||
return new File(Hudson.getInstance().getRootDir(),"plugins/"+getShortName() + ".bak");
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the version of the backed up plugin,
|
||||
* or null if there's no back up.
|
||||
*/
|
||||
public String getBackupVersion() {
|
||||
if (getBackupFile().exists()) {
|
||||
try {
|
||||
JarFile backupPlugin = new JarFile(getBackupFile());
|
||||
return backupPlugin.getManifest().getMainAttributes().getValue("Plugin-Version");
|
||||
} catch (IOException e) {
|
||||
LOGGER.log(WARNING, "Failed to get backup version ", e);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//
|
||||
//
|
||||
// Action methods
|
||||
|
||||
Reference in new issue
Block a user