use of com.qlangtech.tis.extension.util.VersionNumber in project tis by qlangtech.
the class DetachedPluginsUtil method getImpliedDependencies.
/**
* Returns all the plugin dependencies that are implicit based on a particular Jenkins version
*
* @since 2.0
*/
public static List<PluginWrapper.Dependency> getImpliedDependencies(String pluginName, String jenkinsVersion) {
List<PluginWrapper.Dependency> out = new ArrayList<>();
for (DetachedPlugin detached : getDetachedPlugins()) {
// don't fix the dependency for itself, or else we'll have a cycle
if (detached.shortName.equals(pluginName)) {
continue;
}
if (BREAK_CYCLES.contains(pluginName + ' ' + detached.shortName)) {
LOGGER.log(Level.FINE, "skipping implicit dependency {0} → {1}", new Object[] { pluginName, detached.shortName });
continue;
}
// some earlier versions of maven-hpi-plugin apparently puts "null" as a literal in Hudson-Version. watch out for them.
if (jenkinsVersion == null || jenkinsVersion.equals("null") || new VersionNumber(jenkinsVersion).compareTo(detached.splitWhen) <= 0) {
out.add(new PluginWrapper.Dependency(detached.shortName + ':' + detached.requiredVersion + ";resolution:=optional"));
LOGGER.log(Level.FINE, "adding implicit dependency {0} → {1} because of {2}", new Object[] { pluginName, detached.shortName, jenkinsVersion });
}
}
return out;
}
use of com.qlangtech.tis.extension.util.VersionNumber in project tis by qlangtech.
the class InstallUtil method getDefaultInstallState.
private static InstallState getDefaultInstallState() {
// Support a simple state override. Useful for testing.
String stateOverride = System.getProperty("jenkins.install.state", System.getenv("jenkins.install.state"));
if (stateOverride != null) {
try {
return InstallState.valueOf(stateOverride.toUpperCase());
} catch (RuntimeException e) {
throw new IllegalStateException("Unknown install state override specified on the commandline: '" + stateOverride + "'.");
}
}
// Support a 3-state flag for running or disabling the setup wizard
// String shouldRunFlag = SystemProperties.getString("jenkins.install.runSetupWizard");
// boolean shouldRun = "true".equalsIgnoreCase(shouldRunFlag);
// boolean shouldNotRun = "false".equalsIgnoreCase(shouldRunFlag);
// install wizard will always run if environment specified
// if (!shouldRun) {
// if (Functions.getIsUnitTest()) {
// return InstallState.TEST;
// }
//
// if (SystemProperties.getBoolean("hudson.Main.development")) {
// return InstallState.DEVELOPMENT;
// }
// }
// new VersionNumber(getLastExecVersion());
VersionNumber lastRunVersion = null;
// // has the setup wizard been completed?
// if (!SetupWizard.getUpdateStateFile().exists()) {
TIS j = TIS.get();
//
// // Allow for skipping
// if (shouldNotRun) {
// try {
// InstallState.INITIAL_SETUP_COMPLETED.initializeState();
// return j.getInstallState();
// } catch (RuntimeException e) {
// throw e;
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// return InstallState.INITIAL_SECURITY_SETUP;
// }
// We have a last version.
VersionNumber currentRunVersion = new VersionNumber(getCurrentExecVersion());
if (lastRunVersion.isOlderThan(currentRunVersion)) {
return InstallState.UPGRADE;
} else if (lastRunVersion.isNewerThan(currentRunVersion)) {
return InstallState.DOWNGRADE;
} else {
// Last running version was the same as "this" running version.
return InstallState.RESTART;
}
}
Aggregations