mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-29 20:45:20 +00:00
[FIXED JENKINS-3070]
Added uninstaller that removes *.jpi.
This commit is contained in:
1 parent
85eacfe336
commit
29f6a5dd01
5 files changed
+77
-5
No files matched your search
@@ -26,6 +26,7 @@ package hudson;
|
||||
|
||||
import hudson.PluginManager.PluginInstanceStore;
|
||||
import hudson.model.Api;
|
||||
import hudson.model.ModelObject;
|
||||
import jenkins.YesNoMaybe;
|
||||
import jenkins.model.Jenkins;
|
||||
import hudson.model.UpdateCenter;
|
||||
@@ -49,6 +50,7 @@ import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
import org.kohsuke.stapler.export.ExportedBean;
|
||||
import org.kohsuke.stapler.interceptor.RequirePOST;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarFile;
|
||||
@@ -76,7 +78,7 @@ import java.util.jar.JarFile;
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@ExportedBean
|
||||
public class PluginWrapper implements Comparable<PluginWrapper> {
|
||||
public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
/**
|
||||
* {@link PluginManager} to which this belongs to.
|
||||
*/
|
||||
@@ -116,6 +118,11 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
|
||||
*/
|
||||
private final File pinFile;
|
||||
|
||||
/**
|
||||
* A .jpi file, an exploded plugin directory, or a .jpl file.
|
||||
*/
|
||||
private final File archive;
|
||||
|
||||
/**
|
||||
* Short name of the plugin. The artifact Id of the plugin.
|
||||
* This is also used in the URL within Jenkins, so it needs
|
||||
@@ -200,6 +207,11 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
|
||||
this.active = !disableFile.exists();
|
||||
this.dependencies = dependencies;
|
||||
this.optionalDependencies = optionalDependencies;
|
||||
this.archive = archive;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return getLongName();
|
||||
}
|
||||
|
||||
public Api getApi() {
|
||||
@@ -513,6 +525,16 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
|
||||
return pinFile.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this plugin is deleted.
|
||||
*
|
||||
* The plugin continues to function in this session, but in the next session it'll disappear.
|
||||
*/
|
||||
@Exported
|
||||
public boolean isDeleted() {
|
||||
return !archive.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by short name.
|
||||
*/
|
||||
@@ -559,30 +581,41 @@ public class PluginWrapper implements Comparable<PluginWrapper> {
|
||||
// Action methods
|
||||
//
|
||||
//
|
||||
@RequirePOST
|
||||
public HttpResponse doMakeEnabled() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
enable();
|
||||
return HttpResponses.ok();
|
||||
}
|
||||
|
||||
@RequirePOST
|
||||
public HttpResponse doMakeDisabled() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
disable();
|
||||
return HttpResponses.ok();
|
||||
}
|
||||
|
||||
@RequirePOST
|
||||
public HttpResponse doPin() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
new FileOutputStream(pinFile).close();
|
||||
return HttpResponses.ok();
|
||||
}
|
||||
|
||||
@RequirePOST
|
||||
public HttpResponse doUnpin() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
pinFile.delete();
|
||||
return HttpResponses.ok();
|
||||
}
|
||||
|
||||
@RequirePOST
|
||||
public HttpResponse doDoUninstall() throws IOException {
|
||||
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
|
||||
archive.delete();
|
||||
return HttpResponses.redirectViaContextPath("/pluginManager/installed"); // send back to plugin manager
|
||||
}
|
||||
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(PluginWrapper.class.getName());
|
||||
|
||||
|
||||
Reference in new issue
Block a user