@TaskAction public void deleteVersion() { // to enable conventionMappings feature String appName = getAppName(); boolean deleteSourceBundle = isDeleteSourceBundle(); AwsBeanstalkPluginExtension ext = getProject().getExtensions().getByType(AwsBeanstalkPluginExtension.class); AWSElasticBeanstalk eb = ext.getClient(); DescribeEnvironmentsResult der = eb.describeEnvironments(new DescribeEnvironmentsRequest() .withApplicationName(appName)); List<String> usingVersions = der.getEnvironments().stream().map(ed -> ed.getVersionLabel()).collect(Collectors.toList()); DescribeApplicationVersionsResult davr = eb.describeApplicationVersions(new DescribeApplicationVersionsRequest() .withApplicationName(appName)); List<String> versionLabelsToDelete = davr.getApplicationVersions().stream() .filter(avd -> usingVersions.contains(avd.getVersionLabel()) == false && avd.getVersionLabel().contains("-SNAPSHOT-")) .map(avd -> avd.getVersionLabel()).collect(Collectors.toList()); versionLabelsToDelete.forEach(versionLabel -> { getLogger().info("version " + versionLabel + " deleted"); eb.deleteApplicationVersion(new DeleteApplicationVersionRequest() .withApplicationName(appName) .withVersionLabel(versionLabel) .withDeleteSourceBundle(deleteSourceBundle)); }); } }
void deleteVersion(ApplicationVersionDescription versionToRemove) { getLog().info("Must delete version: " + versionToRemove.getVersionLabel()); DeleteApplicationVersionRequest req = new DeleteApplicationVersionRequest() .withApplicationName(versionToRemove.getApplicationName()) // .withDeleteSourceBundle(deleteSourceBundle) // .withVersionLabel(versionToRemove.getVersionLabel()); if (!dryRun) { getService().deleteApplicationVersion(req); deletedVersionsCount++; } }
@TaskAction public void deleteVersion() { // to enable conventionMappings feature String applicationName = getApplicationName(); String versionLabel = getVersionLabel(); boolean deleteSourceBundle = isDeleteSourceBundle(); AwsBeanstalkPluginExtension ext = getProject().getExtensions().getByType(AwsBeanstalkPluginExtension.class); AWSElasticBeanstalk eb = ext.getClient(); eb.deleteApplicationVersion(new DeleteApplicationVersionRequest() .withApplicationName(applicationName) .withVersionLabel(versionLabel) .withDeleteSourceBundle(deleteSourceBundle)); getLogger().info("version " + versionLabel + " deleted"); } }