Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 31 additions & 26 deletions src/main/java/com/amazonaws/codedeploy/AWSCodeDeployPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,42 +244,47 @@ private void verifyCodeDeployApplication(AWSClients aws) throws IllegalArgumentE
}

private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePath workspace) throws IOException, InterruptedException {

File zipFile = File.createTempFile(projectName + "-", ".zip");
this.logger.println("Zipping workspace into " + zipFile.getAbsolutePath());
String key;

try {

workspace.zip(
new FileOutputStream(zipFile),
new DirScanner.Glob(this.includes, this.excludes)
);
this.logger.println("Zipping workspace into " + zipFile.getAbsolutePath());
workspace.zip(
new FileOutputStream(zipFile),
new DirScanner.Glob(this.includes, this.excludes)
);

String key;
if (this.s3prefix.isEmpty()) {
key = zipFile.getName();
} else {
key = this.s3prefix;
if (this.s3prefix.endsWith("/")) {
key += zipFile.getName();
if (this.s3prefix.isEmpty()) {
key = zipFile.getName();
} else {
key += "/" + zipFile.getName();
key = this.s3prefix;
if (this.s3prefix.endsWith("/")) {
key += zipFile.getName();
} else {
key += "/" + zipFile.getName();
}
}
}

logger.println("Uploading zip to s3://" + this.s3bucket + "/" + key);
PutObjectResult s3result = aws.s3.putObject(this.s3bucket, key, zipFile);
logger.println("Uploading zip to s3://" + this.s3bucket + "/" + key);
PutObjectResult s3result = aws.s3.putObject(this.s3bucket, key, zipFile);


S3Location s3Location = new S3Location();
s3Location.setBucket(this.s3bucket);
s3Location.setKey(key);
s3Location.setBundleType(BundleType.Zip);
s3Location.setETag(s3result.getETag());
S3Location s3Location = new S3Location();
s3Location.setBucket(this.s3bucket);
s3Location.setKey(key);
s3Location.setBundleType(BundleType.Zip);
s3Location.setETag(s3result.getETag());

RevisionLocation revisionLocation = new RevisionLocation();
revisionLocation.setRevisionType(RevisionLocationType.S3);
revisionLocation.setS3Location(s3Location);
RevisionLocation revisionLocation = new RevisionLocation();
revisionLocation.setRevisionType(RevisionLocationType.S3);
revisionLocation.setS3Location(s3Location);

return revisionLocation;
return revisionLocation;
} finally {
zipFile.delete();
}
}

private void registerRevision(AWSClients aws, RevisionLocation revisionLocation) {
Expand Down