3434import hudson .FilePath ;
3535import hudson .Launcher ;
3636import hudson .Extension ;
37+ import hudson .Util ;
3738import hudson .model .AbstractBuild ;
3839import hudson .model .BuildListener ;
3940import hudson .model .AbstractProject ;
5859import java .io .IOException ;
5960import java .io .PrintStream ;
6061import java .util .Date ;
62+ import java .util .Map ;
6163import java .util .UUID ;
6264
6365import javax .servlet .ServletException ;
@@ -165,7 +167,7 @@ public AWSCodeDeployPublisher(
165167 }
166168
167169 @ Override
168- public boolean perform (AbstractBuild build , Launcher launcher , BuildListener listener ) {
170+ public boolean perform (AbstractBuild build , Launcher launcher , BuildListener listener ) throws IOException , InterruptedException {
169171
170172 this .logger = listener .getLogger ();
171173 final boolean buildFailed = build .getResult () == Result .FAILURE ;
@@ -205,7 +207,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis
205207 verifyCodeDeployApplication (aws );
206208
207209 String projectName = build .getProject ().getName ();
208- RevisionLocation revisionLocation = zipAndUpload (aws , projectName , build .getWorkspace ());
210+ RevisionLocation revisionLocation = zipAndUpload (aws , projectName , build .getWorkspace (), build . getEnvironment ( listener ) );
209211
210212 registerRevision (aws , revisionLocation );
211213 String deploymentId = createDeployment (aws , revisionLocation );
@@ -243,7 +245,7 @@ private void verifyCodeDeployApplication(AWSClients aws) throws IllegalArgumentE
243245 }
244246 }
245247
246- private RevisionLocation zipAndUpload (AWSClients aws , String projectName , FilePath workspace ) throws IOException , InterruptedException {
248+ private RevisionLocation zipAndUpload (AWSClients aws , String projectName , FilePath workspace , Map < String , String > envVars ) throws IOException , InterruptedException {
247249
248250 File zipFile = File .createTempFile (projectName + "-" , ".zip" );
249251 this .logger .println ("Zipping workspace into " + zipFile .getAbsolutePath ());
@@ -257,7 +259,7 @@ private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePa
257259 if (this .s3prefix .isEmpty ()) {
258260 key = zipFile .getName ();
259261 } else {
260- key = this .s3prefix ;
262+ key = Util . replaceMacro ( this .s3prefix , envVars ) ;
261263 if (this .s3prefix .endsWith ("/" )) {
262264 key += zipFile .getName ();
263265 } else {
0 commit comments