@@ -292,7 +292,31 @@ private void verifyCodeDeployApplication(AWSClients aws) throws IllegalArgumentE
292292
293293 private RevisionLocation zipAndUpload (AWSClients aws , String projectName , FilePath sourceDirectory ) throws IOException , InterruptedException , IllegalArgumentException {
294294
295- File zipFile = File .createTempFile (projectName + "-" , ".zip" );
295+ File zipFile = null ;
296+ File versionFile ;
297+ versionFile = new File (sourceDirectory + "/" + versionFileName );
298+
299+ FileReader reader = null ;
300+ String version = null ;
301+ try {
302+ reader = new FileReader (versionFile );
303+ char [] chars = new char [(int ) versionFile .length () -1 ];
304+ reader .read (chars );
305+ version = new String (chars );
306+ reader .close ();
307+ } catch (IOException e ) {
308+ e .printStackTrace ();
309+ } finally {
310+ if (reader !=null ){reader .close ();}
311+ }
312+
313+ if (version != null ){
314+ zipFile = new File ("/tmp/" + projectName + "-" + version + ".zip" );
315+ zipFile .createNewFile ();
316+ } else {
317+ zipFile = File .createTempFile (projectName + "-" , ".zip" );
318+ }
319+
296320 String key ;
297321 File appspec ;
298322 File dest ;
@@ -340,35 +364,12 @@ private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePa
340364 logger .println ("Uploading zip to s3://" + bucket + "/" + key );
341365 PutObjectResult s3result = aws .s3 .putObject (bucket , key , zipFile );
342366
343- File versionFile ;
344- versionFile = new File (sourceDirectory + "/" + versionFileName );
345-
346- FileReader reader = null ;
347- String version = null ;
348- try {
349- reader = new FileReader (versionFile );
350- char [] chars = new char [(int ) versionFile .length ()];
351- reader .read (chars );
352- version = new String (chars );
353- reader .close ();
354- } catch (IOException e ) {
355- e .printStackTrace ();
356- } finally {
357- if (reader !=null ){reader .close ();}
358- }
359-
360367 S3Location s3Location = new S3Location ();
361368 s3Location .setBucket (bucket );
362369 s3Location .setKey (key );
363370 s3Location .setBundleType (BundleType .Zip );
364371 s3Location .setETag (s3result .getETag ());
365372
366- if (version != null ){
367- s3Location .setVersion (version );
368- }
369-
370-
371-
372373 RevisionLocation revisionLocation = new RevisionLocation ();
373374 revisionLocation .setRevisionType (RevisionLocationType .S3 );
374375 revisionLocation .setS3Location (s3Location );
0 commit comments