@@ -244,42 +244,47 @@ private void verifyCodeDeployApplication(AWSClients aws) throws IllegalArgumentE
244244 }
245245
246246 private RevisionLocation zipAndUpload (AWSClients aws , String projectName , FilePath workspace ) throws IOException , InterruptedException {
247-
247+
248248 File zipFile = File .createTempFile (projectName + "-" , ".zip" );
249- this .logger .println ("Zipping workspace into " + zipFile .getAbsolutePath ());
249+ String key ;
250+
251+ try {
250252
251- workspace .zip (
252- new FileOutputStream (zipFile ),
253- new DirScanner .Glob (this .includes , this .excludes )
254- );
253+ this .logger .println ("Zipping workspace into " + zipFile .getAbsolutePath ());
254+ workspace .zip (
255+ new FileOutputStream (zipFile ),
256+ new DirScanner .Glob (this .includes , this .excludes )
257+ );
255258
256- String key ;
257- if (this .s3prefix .isEmpty ()) {
258- key = zipFile .getName ();
259- } else {
260- key = this .s3prefix ;
261- if (this .s3prefix .endsWith ("/" )) {
262- key += zipFile .getName ();
259+ if (this .s3prefix .isEmpty ()) {
260+ key = zipFile .getName ();
263261 } else {
264- key += "/" + zipFile .getName ();
262+ key = this .s3prefix ;
263+ if (this .s3prefix .endsWith ("/" )) {
264+ key += zipFile .getName ();
265+ } else {
266+ key += "/" + zipFile .getName ();
267+ }
265268 }
266- }
267269
268- logger .println ("Uploading zip to s3://" + this .s3bucket + "/" + key );
269- PutObjectResult s3result = aws .s3 .putObject (this .s3bucket , key , zipFile );
270+ logger .println ("Uploading zip to s3://" + this .s3bucket + "/" + key );
271+ PutObjectResult s3result = aws .s3 .putObject (this .s3bucket , key , zipFile );
270272
271273
272- S3Location s3Location = new S3Location ();
273- s3Location .setBucket (this .s3bucket );
274- s3Location .setKey (key );
275- s3Location .setBundleType (BundleType .Zip );
276- s3Location .setETag (s3result .getETag ());
274+ S3Location s3Location = new S3Location ();
275+ s3Location .setBucket (this .s3bucket );
276+ s3Location .setKey (key );
277+ s3Location .setBundleType (BundleType .Zip );
278+ s3Location .setETag (s3result .getETag ());
277279
278- RevisionLocation revisionLocation = new RevisionLocation ();
279- revisionLocation .setRevisionType (RevisionLocationType .S3 );
280- revisionLocation .setS3Location (s3Location );
280+ RevisionLocation revisionLocation = new RevisionLocation ();
281+ revisionLocation .setRevisionType (RevisionLocationType .S3 );
282+ revisionLocation .setS3Location (s3Location );
281283
282- return revisionLocation ;
284+ return revisionLocation ;
285+ } finally {
286+ zipFile .delete ();
287+ }
283288 }
284289
285290 private void registerRevision (AWSClients aws , RevisionLocation revisionLocation ) {
0 commit comments