未验证 提交 3bcdefca 编写于 作者: J Jesse Glick

[JENKINS-55582] Refinement to at least handle nonstandard...

[JENKINS-55582] Refinement to at least handle nonstandard $JENKINS_HOME/plugins/$shortName.hpi and warn about $shortName-$version.hpi.
上级 1f290ff1
......@@ -186,6 +186,10 @@ public class ClassicPluginStrategy implements PluginStrategy {
} catch (InvalidPathException e) {
throw new IOException(e);
}
String canonicalName = manifest.getMainAttributes().getValue("Short-Name") + ".jpi";
if (!archive.getName().equals(canonicalName)) {
LOGGER.warning(() -> "encountered " + archive + " under a nonstandard name; expected " + canonicalName);
}
}
final Attributes atts = manifest.getMainAttributes();
......
......@@ -601,7 +601,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
}
void considerDetachedPlugin(String shortName) {
if (new File(rootDir, shortName + ".jpi").isFile()) {
if (new File(rootDir, shortName + ".jpi").isFile() || new File(rootDir, shortName + ".hpi").isFile()) {
LOGGER.fine(() -> "not considering loading a detached dependency " + shortName + " as it is already on disk");
return;
}
......
......@@ -184,6 +184,20 @@ public class LoadDetachedPluginsTest {
assertEquals(expectedPlugin, pw.getShortName());
}
@Issue("JENKINS-55582")
@LocalData
@Test
public void nonstandardFilenames() {
logging.record(PluginManager.class, Level.FINE).record(ClassicPluginStrategy.class, Level.FINE);
rr.then(r -> {
assertTrue(r.jenkins.pluginManager.getPlugin("build-token-root").isActive());
assertEquals("1.2", r.jenkins.pluginManager.getPlugin("jdk-tool").getVersion());
/* TODO currently still loads the detached 1.0, since we only skip $shortName.[jh]pi not $shortName-$version.[jh]pi; during PLUGINS_LISTED there is a list of known filenames but not short names
assertEquals("1.3", r.jenkins.pluginManager.getPlugin("command-launcher").getVersion());
*/
});
}
private List<PluginWrapper> getInstalledDetachedPlugins(JenkinsRule r, List<DetachedPlugin> detachedPlugins) {
PluginManager pluginManager = r.jenkins.getPluginManager();
List<PluginWrapper> installedPlugins = new ArrayList<>();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册