提交 5ecbbefb 编写于 作者: J Jesse Glick

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

上级 8c53e2f3
......@@ -58,6 +58,9 @@ Upcoming changes</a>
<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 abstract class PluginManager extends AbstractModelObject implements OnMas
}
// 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.Level;
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 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
* @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 class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
}
public void run() {
if (ID_UPLOAD.equals(site.getId())) {
return;
}
LOGGER.fine("Doing a connectivity check");
try {
String connectionCheckUrl = site.getConnectionCheckUrl();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册