Skip to content
Permalink
Browse files

[FIXED JENKINS-16652] Use UpdateSite.Plugin.deploy from PluginManager…

….doUploadPlugin.
  • Loading branch information
jglick committed May 15, 2013
1 parent 8c53e2f commit 5ecbbefb6d83fbc4c8919b94b33f491fa0e0055f
Showing with 22 additions and 13 deletions.
  1. +3 −0 changelog.html
  2. +11 −13 core/src/main/java/hudson/PluginManager.java
  3. +8 −0 core/src/main/java/hudson/model/UpdateCenter.java
@@ -58,6 +58,9 @@
<li class=bug>
NPE from <code>Run.getDynamic</code>.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17935">issue 17935</a>)
<li class=bug>
Reworked Upload Plugin gesture to work more like installation from an update center, and in particular to support dynamic load.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16652">issue 16652</a>)
<li class=bug>
Errors in <code>init.groovy</code> halted startup; changed to just log a warning.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17933">issue 17933</a>)
@@ -732,25 +732,23 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
}

// first copy into a temporary file name
File t = File.createTempFile("uploaded", "jp_",rootDir);
fileItem.write(t); // rename all new plugins to *.jpi
File t = File.createTempFile("uploaded", ".jpi");
t.deleteOnExit();
fileItem.write(t);
fileItem.delete();

final String baseName = identifyPluginShortName(t);

// and move the temp file into a proper name
new File(rootDir, baseName + ".hpi").delete(); // don't keep confusing legacy *.hpi
new File(rootDir, baseName + ".jpi").delete(); // rename can fail if the file already exists
t.renameTo(new File(rootDir, baseName + ".jpi"));

PluginWrapper existing = getPlugin(baseName);
if (existing!=null && existing.isBundled){
existing.doPin();
}

pluginUploaded = true;

return new HttpRedirect(".");
// Now create a dummy plugin that we can dynamically load (the InstallationJob will force a restart if one is needed):
JSONObject cfg = new JSONObject().
element("name", baseName).
element("version", "0"). // unused but mandatory
element("url", t.toURI().toString()).
element("dependencies", new JSONArray());
new UpdateSite(UpdateCenter.ID_UPLOAD, null).new Plugin(UpdateCenter.ID_UPLOAD, cfg).deploy(true);
return new HttpRedirect("../updateCenter");
} catch (IOException e) {
throw e;
} catch (Exception e) {// grrr. fileItem.write throws this
@@ -89,6 +89,8 @@
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.acegisecurity.context.SecurityContextHolder;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import org.kohsuke.stapler.interceptor.RequirePOST;
@@ -119,6 +121,9 @@
* @since 1.483
*/
public static final String ID_DEFAULT = "default";

@Restricted(NoExternalUse.class)
public static final String ID_UPLOAD = "_upload";

/**
* {@link ExecutorService} that performs installation.
@@ -1012,6 +1017,9 @@ public ConnectionCheckJob(UpdateSite site) {
}

public void run() {
if (ID_UPLOAD.equals(site.getId())) {
return;
}
LOGGER.fine("Doing a connectivity check");
try {
String connectionCheckUrl = site.getConnectionCheckUrl();

0 comments on commit 5ecbbef

Please sign in to comment.
You can’t perform that action at this time.