@@ -378,22 +378,12 @@ def upload_archive(self):
378378 testresult_exists = False
379379
380380 if os .path .exists (self .infrabox_archive_dir ):
381- files = self .get_files_in_dir (self .infrabox_archive_dir )
382-
383- if files :
384- c .collect ("Uploading /infrabox/upload/archive" , show = True )
381+ if self .get_files_in_dir (self .infrabox_archive_dir ):
385382 archive_exists = True
386- for f in files :
387- c .collect ("%s" % f , show = True )
388- self .post_file_to_api_server ("/archive" , f , filename = f .replace (self .infrabox_upload_dir + '/' , '' ))
389383
390384 if os .path .exists (self .infrabox_testresult_dir ):
391- files = self .get_files_in_dir (self .infrabox_testresult_dir )
392-
393- if files :
385+ if self .get_files_in_dir (self .infrabox_testresult_dir ):
394386 testresult_exists = True
395- for f in files :
396- c .collect ("%s" % f , show = True )
397387
398388 tar_file = os .path .join (self .infrabox_upload_dir , 'all_archives' + '.tar.gz' )
399389 with tarfile .open (tar_file , mode = 'w:gz' ) as archive :
@@ -404,6 +394,12 @@ def upload_archive(self):
404394
405395 self .post_file_to_api_server ("/archive" , tar_file )
406396
397+ if archive_exists :
398+ c .collect ("Uploading /infrabox/upload/archive" , show = True )
399+ for f in self .get_files_in_dir (self .infrabox_archive_dir ):
400+ c .collect ("%s" % f , show = True )
401+ self .post_file_to_api_server ("/archive" , f , filename = f .replace (self .infrabox_upload_dir + '/' , '' ))
402+
407403
408404 def upload_coverage_results (self ):
409405 if not os .path .exists (self .infrabox_coverage_dir ):
@@ -501,16 +497,24 @@ def _get_size(self, start_path):
501497 return total_size
502498
503499 def finalize_upload (self ):
500+ self .upload_archive ()
504501 self .upload_coverage_results ()
505502 self .upload_test_results ()
506503 self .upload_markup_files ()
507504 self .upload_badge_files ()
508- self .upload_archive ()
509505
510506 def handle_abort (self , signum , sigframe ):
511507 if not self .aborted :
512508 self .aborted = True
513509 self .console .collect ("##Aborted" , show = True )
510+ if hasattr (self , '_compose_file_new' ):
511+ try :
512+ subprocess .call (
513+ ['docker-compose' , '-f' , self ._compose_file_new , 'stop' , '--timeout' , '30' ],
514+ env = self .environment ,
515+ timeout = 35 )
516+ except Exception :
517+ pass
514518 self .finalize_upload ()
515519
516520 def main_run_job (self ):
@@ -722,6 +726,8 @@ def run_job_docker_compose(self, c):
722726 with open (compose_file_new , "w+" ) as out :
723727 json .dump (compose_file_content , out )
724728
729+ self ._compose_file_new = compose_file_new
730+
725731 collector = StatsCollector ()
726732
727733 self ._login_source_registries ()
0 commit comments