use of org.jenkinsci.test.acceptance.po.UpdateCenter.InstallationFailedException in project acceptance-test-harness by jenkinsci.
the class TSRPluginManager method installPlugins.
/**
* Installs specified plugins.
*
* deprecated Please be encouraged to use {@link WithPlugins} annotations to statically declare
* the required plugins you need. If you really do need to install plugins in the middle
* of a test, as opposed to be in the beginning, then this is the right method.
* <p/>
* The deprecation marker is to call attention to {@link WithPlugins}. This method
* is not really deprecated.
*/
@Deprecated
public void installPlugins(final String... specs) {
final Map<String, String> candidates = getMapShortNamesVersion(specs);
if (uploadPlugins) {
for (PluginMetadata newPlugin : ucmd.get().transitiveDependenciesOf(candidates.keySet())) {
final String name = newPlugin.name;
final String claimedVersion = candidates.get(name);
String currentSpec;
if (StringUtils.isNotEmpty(claimedVersion)) {
currentSpec = name + "@" + claimedVersion;
} else {
currentSpec = name;
}
if (!isInstalled(currentSpec)) {
// we need to override existing "old" plugins
try {
newPlugin.uploadTo(jenkins, injector, null);
} catch (IOException | ArtifactResolutionException e) {
throw new AssertionError("Failed to upload plugin: " + newPlugin, e);
}
}
}
// TODO: Use better detection if this is actually necessary
try {
waitForCond(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return isInstalled(specs);
}
}, 5);
} catch (TimeoutException e) {
jenkins.restart();
}
} else {
if (!updated)
checkForUpdates();
OUTER: for (final String n : candidates.keySet()) {
for (int attempt = 0; attempt < 2; attempt++) {
// # of installations attempted, considering retries
visit("available");
check(find(by.xpath("//input[starts-with(@name,'plugin.%s.')]", n)));
clickButton("Install");
sleep(1000);
try {
new UpdateCenter(jenkins).waitForInstallationToComplete(n);
} catch (InstallationFailedException e) {
if (e.getMessage().contains("Failed to download from")) {
// retry
continue;
}
}
// installation completed
continue OUTER;
}
}
}
}
Aggregations