Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import hudson.FilePath;
import hudson.Launcher;
import hudson.Extension;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.AbstractProject;
Expand All @@ -58,6 +59,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.util.Date;
import java.util.Map;
import java.util.UUID;

import javax.servlet.ServletException;
Expand Down Expand Up @@ -165,7 +167,7 @@ public AWSCodeDeployPublisher(
}

@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {

this.logger = listener.getLogger();
final boolean buildFailed = build.getResult() == Result.FAILURE;
Expand Down Expand Up @@ -205,7 +207,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
verifyCodeDeployApplication(aws);

String projectName = build.getProject().getName();
RevisionLocation revisionLocation = zipAndUpload(aws, projectName, build.getWorkspace());
RevisionLocation revisionLocation = zipAndUpload(aws, projectName, build.getWorkspace(), build.getEnvironment(listener));

registerRevision(aws, revisionLocation);
String deploymentId = createDeployment(aws, revisionLocation);
Expand Down Expand Up @@ -243,7 +245,7 @@ private void verifyCodeDeployApplication(AWSClients aws) throws IllegalArgumentE
}
}

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

File zipFile = File.createTempFile(projectName + "-", ".zip");
this.logger.println("Zipping workspace into " + zipFile.getAbsolutePath());
Expand All @@ -257,7 +259,7 @@ private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePa
if (this.s3prefix.isEmpty()) {
key = zipFile.getName();
} else {
key = this.s3prefix;
key = Util.replaceMacro(this.s3prefix, envVars);
if (this.s3prefix.endsWith("/")) {
key += zipFile.getName();
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div>
The prefix in the S3 Bucket to prepend to the AWS CodeDeploy revision. Default is the root of the bucket.
The prefix in the S3 Bucket to prepend to the AWS CodeDeploy revision. Default is the root of the bucket. You can
use environment variables in this field.
</div>