mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-09 10:06:13 +00:00
Merge pull request #4039 from jglick/nonstandardFilenames-JENKINS-55582
[JENKINS-55582] Handle nonstandard $JENKINS_HOME/plugins/$shortName.hpi and warn about $shortName-$version.hpi
This commit is contained in:
6 files changed
+19
-1
No files matched your search
@@ -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<>();
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in new issue
Block a user