@Test public void checkVersionCompatibilityNullTest() { Plugin plugin1 = new Plugin("plugin1", "1.0", null, null); plugin1.setJenkinsVersion("2.121.2"); Plugin plugin2 = new Plugin("plugin2", "2.1.1", null, null); plugin2.setJenkinsVersion("1.609.3"); pm.checkVersionCompatibility(null, Arrays.asList(plugin1, plugin2)); }
public void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded) { if (jenkinsVersion != null && !StringUtils.isEmpty(jenkinsVersion.toString())) { for (Plugin p : pluginsToBeDownloaded) { if (p.getJenkinsVersion() != null) { if (p.getJenkinsVersion().isNewerThan(jenkinsVersion)) { throw new VersionCompatibilityException( String.format("%n%s (%s) requires a greater version of Jenkins (%s) than %s in %s", p.getName(), p.getVersion().toString(), p.getJenkinsVersion().toString(), jenkinsVersion.toString(), jenkinsWarFile.toString())); } } } } }
PluginManager { public void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded) { if (jenkinsVersion != null && !StringUtils.isEmpty(jenkinsVersion.toString())) { for (Plugin p : pluginsToBeDownloaded) { if (p.getJenkinsVersion() != null) { if (p.getJenkinsVersion().isNewerThan(jenkinsVersion)) { throw new VersionCompatibilityException( String.format("%n%s (%s) requires a greater version of Jenkins (%s) than %s in %s", p.getName(), p.getVersion().toString(), p.getJenkinsVersion().toString(), jenkinsVersion.toString(), jenkinsWarFile.toString())); } } } } } }
PluginManager { public void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded) { if (jenkinsVersion != null && !StringUtils.isEmpty(jenkinsVersion.toString())) { for (Plugin p : pluginsToBeDownloaded) { if (p.getJenkinsVersion() != null) { if (p.getJenkinsVersion().isNewerThan(jenkinsVersion)) { throw new VersionCompatibilityException( String.format("%n%s (%s) requires a greater version of Jenkins (%s) than %s in %s", p.getName(), p.getVersion().toString(), p.getJenkinsVersion().toString(), jenkinsVersion.toString(), jenkinsWarFile.toString())); } } } } } @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "we want the user to be able to specify a path")  PluginManager(Config cfg); }
PluginManager { public void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded) { if (jenkinsVersion != null && !StringUtils.isEmpty(jenkinsVersion.toString())) { for (Plugin p : pluginsToBeDownloaded) { if (p.getJenkinsVersion() != null) { if (p.getJenkinsVersion().isNewerThan(jenkinsVersion)) { throw new VersionCompatibilityException( String.format("%n%s (%s) requires a greater version of Jenkins (%s) than %s in %s", p.getName(), p.getVersion().toString(), p.getJenkinsVersion().toString(), jenkinsVersion.toString(), jenkinsWarFile.toString())); } } } } } @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "we want the user to be able to specify a path")  PluginManager(Config cfg); void start(); void start(boolean downloadUc); List<Plugin> findPluginsToDownload(Map<String, Plugin> requestedPlugins); Map<String, Plugin> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded); void listPlugins(); void logPlugins(String description, List<Plugin> plugins); Map<String, List<SecurityWarning>> getSecurityWarnings(); void showAllSecurityWarnings(); void showSpecificSecurityWarnings(List<Plugin> plugins); List<Plugin> getLatestVersionsOfPlugins(List<Plugin> plugins); boolean warningExists(Plugin plugin); void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded); void downloadPlugins(List<Plugin> plugins); Map<String, Plugin> findPluginsAndDependencies(List<Plugin> requestedPlugins); void outputPluginReplacementInfo(Plugin lowerVersion, Plugin higherVersion); @Deprecated JSONObject getJson(String urlString); JSONObject getJson(URL url, String cacheKey); void getUCJson(VersionNumber jenkinsVersion); JSONArray getPluginDependencyJsonArray(Plugin plugin, JSONObject ucJson); VersionNumber getLatestPluginVersion(String pluginName); List<Plugin> resolveDependenciesFromManifest(Plugin plugin); List<Plugin> resolveDependenciesFromJson(Plugin plugin, JSONObject pluginJson); List<Plugin> resolveDirectDependencies(Plugin plugin); Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin); boolean downloadPlugin(Plugin plugin, File location); String getPluginDownloadUrl(Plugin plugin); boolean downloadToFile(String urlString, Plugin plugin, File fileLocation); @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "PATH_TRAVERSAL_IN"}) boolean downloadToFile(String urlString, Plugin plugin, File fileLocation, int maxRetries); String getAttributeFromManifest(File file, String key); VersionNumber getJenkinsVersionFromWar(); String getPluginVersion(File file); Map<String, Plugin> installedPlugins(); @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "PATH_TRAVERSAL_IN"}) Map<String, Plugin> bundledPlugins(); String getJenkinsUCLatest(); void setJenkinsUCLatest(String updateCenterLatest); void setInstalledPluginVersions(Map<String, Plugin> installedPlugins); void setBundledPluginVersions(Map<String, Plugin> bundledPlugins); void setAllPluginsAndDependencies(Map<String, Plugin> allPluginsAndDependencies); void setEffectivePlugins(Map<String, Plugin> effectivePlugins); void setPluginsToBeDownloaded(List<Plugin> pluginsToBeDownloaded); void logVerbose(String message); void setLatestUcJson(JSONObject latestUcJson); void setLatestUcPlugins(JSONObject latestPlugins); void setExperimentalUcJson(JSONObject experimentalUcJson); void setAllSecurityWarnings(Map<String, List<SecurityWarning>> securityWarnings); void setPluginInfoJson(JSONObject pluginInfoJson); void setCm(CacheManager cm); List<Plugin> getFailedPlugins(); }
PluginManager { public void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded) { if (jenkinsVersion != null && !StringUtils.isEmpty(jenkinsVersion.toString())) { for (Plugin p : pluginsToBeDownloaded) { if (p.getJenkinsVersion() != null) { if (p.getJenkinsVersion().isNewerThan(jenkinsVersion)) { throw new VersionCompatibilityException( String.format("%n%s (%s) requires a greater version of Jenkins (%s) than %s in %s", p.getName(), p.getVersion().toString(), p.getJenkinsVersion().toString(), jenkinsVersion.toString(), jenkinsWarFile.toString())); } } } } } @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "we want the user to be able to specify a path")  PluginManager(Config cfg); void start(); void start(boolean downloadUc); List<Plugin> findPluginsToDownload(Map<String, Plugin> requestedPlugins); Map<String, Plugin> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded); void listPlugins(); void logPlugins(String description, List<Plugin> plugins); Map<String, List<SecurityWarning>> getSecurityWarnings(); void showAllSecurityWarnings(); void showSpecificSecurityWarnings(List<Plugin> plugins); List<Plugin> getLatestVersionsOfPlugins(List<Plugin> plugins); boolean warningExists(Plugin plugin); void checkVersionCompatibility(VersionNumber jenkinsVersion, List<Plugin> pluginsToBeDownloaded); void downloadPlugins(List<Plugin> plugins); Map<String, Plugin> findPluginsAndDependencies(List<Plugin> requestedPlugins); void outputPluginReplacementInfo(Plugin lowerVersion, Plugin higherVersion); @Deprecated JSONObject getJson(String urlString); JSONObject getJson(URL url, String cacheKey); void getUCJson(VersionNumber jenkinsVersion); JSONArray getPluginDependencyJsonArray(Plugin plugin, JSONObject ucJson); VersionNumber getLatestPluginVersion(String pluginName); List<Plugin> resolveDependenciesFromManifest(Plugin plugin); List<Plugin> resolveDependenciesFromJson(Plugin plugin, JSONObject pluginJson); List<Plugin> resolveDirectDependencies(Plugin plugin); Map<String, Plugin> resolveRecursiveDependencies(Plugin plugin); boolean downloadPlugin(Plugin plugin, File location); String getPluginDownloadUrl(Plugin plugin); boolean downloadToFile(String urlString, Plugin plugin, File fileLocation); @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "PATH_TRAVERSAL_IN"}) boolean downloadToFile(String urlString, Plugin plugin, File fileLocation, int maxRetries); String getAttributeFromManifest(File file, String key); VersionNumber getJenkinsVersionFromWar(); String getPluginVersion(File file); Map<String, Plugin> installedPlugins(); @SuppressFBWarnings({"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "PATH_TRAVERSAL_IN"}) Map<String, Plugin> bundledPlugins(); String getJenkinsUCLatest(); void setJenkinsUCLatest(String updateCenterLatest); void setInstalledPluginVersions(Map<String, Plugin> installedPlugins); void setBundledPluginVersions(Map<String, Plugin> bundledPlugins); void setAllPluginsAndDependencies(Map<String, Plugin> allPluginsAndDependencies); void setEffectivePlugins(Map<String, Plugin> effectivePlugins); void setPluginsToBeDownloaded(List<Plugin> pluginsToBeDownloaded); void logVerbose(String message); void setLatestUcJson(JSONObject latestUcJson); void setLatestUcPlugins(JSONObject latestPlugins); void setExperimentalUcJson(JSONObject experimentalUcJson); void setAllSecurityWarnings(Map<String, List<SecurityWarning>> securityWarnings); void setPluginInfoJson(JSONObject pluginInfoJson); void setCm(CacheManager cm); List<Plugin> getFailedPlugins();  }