def build_bundle(version_label): if not os.path.exists('.elasticbeanstalk'): os.mkdir('.elasticbeanstalk') file_path = fileoperations.get_zip_location('{}.zip'.format(version_label)) logging.info('Packaging application to %s', file_path) ignore_files = fileoperations.get_ebignore_list() fileoperations.io.log_info = lambda message: logging.debug(message) fileoperations.zip_up_project(file_path, ignore_list=ignore_files) return '.elasticbeanstalk/app_versions/{}.zip'.format(version_label)
def _zip_up_project(version_label, source_control, staged=False): file_name = version_label + '.zip' file_path = fileoperations.get_zip_location(file_name) if not fileoperations.file_exists(file_path): io.echo(strings['appversion.create'].replace('{version}', version_label)) ignore_files = fileoperations.get_ebignore_list() if ignore_files is None: source_control.do_zip(file_path, staged) else: io.log_info('Found .ebignore, using system zip.') fileoperations.zip_up_project(file_path, ignore_list=ignore_files) return file_name, file_path
def _zip_up_project(version_label, source_control, staged=False): # Create zip file file_name = version_label + '.zip' file_path = fileoperations.get_zip_location(file_name) # Check to see if file already exists from previous attempt if not fileoperations.file_exists(file_path): # If it doesn't already exist, create it io.echo(strings['appversion.create'].replace('{version}', version_label)) ignore_files = fileoperations.get_ebignore_list() if ignore_files is None: source_control.do_zip(file_path, staged) else: io.log_info('Found .ebignore, using system zip.') fileoperations.zip_up_project(file_path, ignore_list=ignore_files) return file_name, file_path
def test_get_zip_location(self): self.assertEqual( os.path.join(os.path.abspath('.'), '.elasticbeanstalk', 'app_versions', 'some-file'), fileoperations.get_zip_location('some-file'))
#!/usr/bin/env python """ Helper for creating a zip file for consumption by elasticbeanstalk. Runs similar code to `eb deploy` from ebcli, but will just create the zipfile. This allows us to be specific about the name and bind it to our branch & build number for later deployment. """ import logging import sys import ebcli.core.fileoperations as fileoperations logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') if len(sys.argv) != 2: print("Usage: {} FILENAME".format(sys.argv[0])) print("Ex: {} myapp-BRANCH-BUILDNUMBER.zip".format(sys.argv[0])) sys.exit(1) file_name = sys.argv[1] file_path = fileoperations.get_zip_location(file_name) logging.info('Packaging application to %s', file_path) ignore_files = fileoperations.get_ebignore_list() fileoperations.io.log_info = lambda message: logging.debug(message) fileoperations.zip_up_project(file_path, ignore_list=ignore_files)