if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(","); if (getVersionLabel() != null) sb.append("VersionLabel: ").append(getVersionLabel()).append(","); if (getSourceBuildInformation() != null) sb.append("SourceBuildInformation: ").append(getSourceBuildInformation()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getApplicationVersionArn() == null) ? 0 : getApplicationVersionArn().hashCode()); hashCode = prime * hashCode + ((getApplicationName() == null) ? 0 : getApplicationName().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getVersionLabel() == null) ? 0 : getVersionLabel().hashCode()); hashCode = prime * hashCode + ((getSourceBuildInformation() == null) ? 0 : getSourceBuildInformation().hashCode()); hashCode = prime * hashCode + ((getBuildArn() == null) ? 0 : getBuildArn().hashCode()); hashCode = prime * hashCode + ((getSourceBundle() == null) ? 0 : getSourceBundle().hashCode()); hashCode = prime * hashCode + ((getDateCreated() == null) ? 0 : getDateCreated().hashCode()); hashCode = prime * hashCode + ((getDateUpdated() == null) ? 0 : getDateUpdated().hashCode()); hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); return hashCode; }
if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; if (other.getVersionLabel() == null ^ this.getVersionLabel() == null) return false; if (other.getVersionLabel() != null && other.getVersionLabel().equals(this.getVersionLabel()) == false) return false; if (other.getSourceBuildInformation() == null ^ this.getSourceBuildInformation() == null)
void filterAppVersionListByVersionLabelPattern(List<ApplicationVersionDescription> appVersionList, String patternString) { if (patternString == null) { return; } getLog().info("Filtering versions with pattern : " + patternString); Pattern p = Pattern.compile(patternString); for (ListIterator<ApplicationVersionDescription> appVersionIterator = appVersionList.listIterator(); appVersionIterator.hasNext(); ) { if (!p.matcher(appVersionIterator.next().getVersionLabel()).matches()) { appVersionIterator.remove(); } } } }
protected String lookupVersionLabelForCommitId(String commitId) throws Exception { String versionLabel = null; String prefixToLookup = format("git-%s-", commitId); DescribeApplicationVersionsResult describeApplicationVersions = getService().describeApplicationVersions(new DescribeApplicationVersionsRequest().withApplicationName(applicationName)); for (ApplicationVersionDescription avd : describeApplicationVersions.getApplicationVersions()) { if (avd.getVersionLabel().startsWith(prefixToLookup)) { versionLabel = avd.getVersionLabel(); break; } } return versionLabel; }
public void deleteOldVersions(String applicationName) { DescribeApplicationVersionsRequest search = new DescribeApplicationVersionsRequest(); search.setApplicationName(applicationName); List<ApplicationVersionDescription> versions = elasticBeanstalk.describeApplicationVersions(search).getApplicationVersions(); List<ApplicationVersionDescription> versionsToRemove = versionsToRemove(versions); Set<String> deployedLabels = findDeployedLabels(applicationName); log.info("Removing {} oldest versions of total {} versions", versionsToRemove.size(), versions.size()); for (ApplicationVersionDescription version : versionsToRemove) { if (deployedLabels.contains(version.getVersionLabel())) { log.info("Not removing version {} because it is deployed", version.getVersionLabel()); } else { deleteApplicationVersion(version); } } }
public void deleteApplicationVersion(ApplicationVersionDescription version) { log.info("Deleting application version {}", version.getVersionLabel()); DeleteApplicationVersionRequest deleteRequest = new DeleteApplicationVersionRequest(); deleteRequest.setApplicationName(version.getApplicationName()); deleteRequest.setVersionLabel(version.getVersionLabel()); deleteRequest.setDeleteSourceBundle(true); elasticBeanstalk.deleteApplicationVersion(deleteRequest); }
public void deleteOldVersions(String applicationName) { DescribeApplicationVersionsRequest search = new DescribeApplicationVersionsRequest(); search.setApplicationName(applicationName); List<ApplicationVersionDescription> versions = elasticBeanstalk.describeApplicationVersions(search).getApplicationVersions(); List<ApplicationVersionDescription> versionsToRemove = versionsToRemove(versions); Set<String> deployedLabels = findDeployedLabels(applicationName); log.info("Removing {} oldest versions of total {} versions", versionsToRemove.size(), versions.size()); for (ApplicationVersionDescription version : versionsToRemove) { if (deployedLabels.contains(version.getVersionLabel())) { log.info("Not removing version {} because it is deployed", version.getVersionLabel()); } else { deleteApplicationVersion(version); } } }
public void deleteApplicationVersion(ApplicationVersionDescription version) { log.info("Deleting application version {}", version.getVersionLabel()); DeleteApplicationVersionRequest deleteRequest = new DeleteApplicationVersionRequest(); deleteRequest.setApplicationName(version.getApplicationName()); deleteRequest.setVersionLabel(version.getVersionLabel()); deleteRequest.setDeleteSourceBundle(true); elasticBeanstalk.deleteApplicationVersion(deleteRequest); }
public void deploy(File warFile, String applicationName, String environmentName, String templateName, String versionLabel) { log.info("Starting deployment of {}", applicationName); S3Location bundle = uploadCodeBundle(warFile); ApplicationVersionDescription version = createApplicationVersion(bundle, applicationName, versionLabel); deployNewVersion(version.getVersionLabel(), environmentName, applicationName, templateName); deleteOldVersions(applicationName); }
public void deploy(File warFile, String applicationName, String environmentName, String templateName, String versionLabel) { log.info("Starting deployment of {}", applicationName); S3Location bundle = uploadCodeBundle(warFile); ApplicationVersionDescription version = createApplicationVersion(bundle, applicationName, versionLabel); deployNewVersion(version.getVersionLabel(), environmentName, applicationName, templateName); deleteOldVersions(applicationName); }
versionLabel = appVersionList.get(0).getVersionLabel();
if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(","); if (getVersionLabel() != null) sb.append("VersionLabel: ").append(getVersionLabel()).append(","); if (getSourceBuildInformation() != null) sb.append("SourceBuildInformation: ").append(getSourceBuildInformation()).append(",");
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 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)); }); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getApplicationVersionArn() == null) ? 0 : getApplicationVersionArn().hashCode()); hashCode = prime * hashCode + ((getApplicationName() == null) ? 0 : getApplicationName().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getVersionLabel() == null) ? 0 : getVersionLabel().hashCode()); hashCode = prime * hashCode + ((getSourceBuildInformation() == null) ? 0 : getSourceBuildInformation().hashCode()); hashCode = prime * hashCode + ((getBuildArn() == null) ? 0 : getBuildArn().hashCode()); hashCode = prime * hashCode + ((getSourceBundle() == null) ? 0 : getSourceBundle().hashCode()); hashCode = prime * hashCode + ((getDateCreated() == null) ? 0 : getDateCreated().hashCode()); hashCode = prime * hashCode + ((getDateUpdated() == null) ? 0 : getDateUpdated().hashCode()); hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); return hashCode; }
Object changeToVersion(EnvironmentDescription d, ApplicationVersionDescription latestVersionDescription) { String curVersionLabel = d.getVersionLabel(); String versionLabel = latestVersionDescription.getVersionLabel(); UpdateEnvironmentRequest request = new UpdateEnvironmentRequest().withEnvironmentId(d.getEnvironmentId()).withVersionLabel(versionLabel); getLog() .info( "Changing versionLabel for Environment[name=" + curEnv.getEnvironmentName() + "; environmentId=" + curEnv.getEnvironmentId() + "] from version " + curVersionLabel + " to version " + latestVersionDescription.getVersionLabel()); if (dryRun) { return null; } return getService().updateEnvironment(request); } }
ApplicationVersionDescription versionDescription = versionIterator.next(); String versionLabel = versionDescription.getVersionLabel();
if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false; if (other.getVersionLabel() == null ^ this.getVersionLabel() == null) return false; if (other.getVersionLabel() != null && other.getVersionLabel().equals(this.getVersionLabel()) == false) return false; if (other.getSourceBuildInformation() == null ^ this.getSourceBuildInformation() == null)
@Override public boolean perform() { log("Creating application version %s for application %s for path %s", getVersionLabel(), c.config.getApplicationName(), getS3ObjectPath()); CreateApplicationVersionRequest cavRequest = new CreateApplicationVersionRequest() .withApplicationName(c.config.getApplicationName()) .withAutoCreateApplication(true) .withSourceBundle(new S3Location(c.config.getBucketName(), getObjectKey())) .withVersionLabel(getVersionLabel()) .withDescription(getVersionDescription()); final CreateApplicationVersionResult result = getAwseb().createApplicationVersion(cavRequest); log("Created version: %s", result.getApplicationVersion().getVersionLabel()); return false; } }