def run(self): try: self.configure() generator = self.generator # Now we can fetch repositories of modules (we have all overrides) get_dependencies(generator.image, os.path.join(self.args.target, 'repo')) # We have all overrided repo fetch so we can discover modules # and process its dependency trees discover_modules(os.path.join(self.args.target, 'repo')) generator.prepare_modules() if self.args.build_tech_preview: generator.generate_tech_preview() # if tags are not specified on command line we take them from image descriptor if not self.args.tags: self.args.tags = generator.get_tags() # we run generate for build command too if set(['generate', 'build']).intersection(set(self.args.commands)): generator.prepare_repositories() generator.image.remove_none_keys() generator.prepare_artifacts() generator.image.write( os.path.join(self.args.target, 'image.yaml')) generator.render_dockerfile() if 'build' in self.args.commands: params = { 'user': self.args.build_osbs_user, 'nowait': self.args.build_osbs_nowait, 'stage': self.args.build_osbs_stage, 'release': self.args.build_osbs_release, 'tags': self.args.tags, 'pull': self.args.build_pull, 'redhat': config.get('common', 'redhat'), 'target': self.args.build_osbs_target, 'commit_msg': self.args.build_osbs_commit_msg } builder = Builder(self.args.build_engine, self.args.target, params) builder.prepare(generator.image) builder.build() if 'test' in self.args.commands: test_tags = [generator.get_tags()[0]] # if wip is specifed set tags to @wip if self.args.test_wip: test_tags = ['@wip'] # at first we collect tests tc = TestCollector(os.path.dirname(self.args.descriptor), self.args.target) # we run the test only if we collect any if tc.collect(generator.image.get('schema_version'), self.args.test_steps_url): runner = TestRunner(self.args.target) runner.run(self.args.tags[0], test_tags, test_names=self.args.test_names) else: logger.warning("No test collected, test can't be run.") logger.info("Finished!") sys.exit(0) except KeyboardInterrupt as e: pass except CekitError as e: if self.args.verbose: logger.exception(e) else: logger.error(e.message) sys.exit(1)
def run(self): if self.args.verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) logger.debug("Running version %s", version) if 'dev' in version: logger.warning("You are running unreleased development version of Cekit, " "use it only at your own risk!") try: tools.cfg = tools.get_cfg(self.args.config) tools.cleanup(self.args.target) if self.args.redhat: tools.cfg['common']['redhat'] = True if self.args.work_dir: tools.cfg['common']['work_dir'] = self.args.work_dir # We need to construct Generator first, because we need overrides # merged in params = {'redhat': tools.cfg['common']['redhat']} generator = Generator(self.args.descriptor, self.args.target, self.args.build_engine, self.args.overrides, params) # Now we can fetch repositories of modules (we have all overrides) get_dependencies(generator.image, os.path.join(self.args.target, 'repo')) # We have all overrided repo fetch so we can discover modules # and process its dependency trees discover_modules(os.path.join(self.args.target, 'repo')) # we run generate for every possible command if self.args.commands: generator.prepare_modules() generator.prepare_repositories() generator.prepare_artifacts() if self.args.build_tech_preview: generator.generate_tech_preview() generator.image.write(os.path.join(self.args.target, 'image.yaml')) generator.render_dockerfile() # if tags are not specified on command line we take them from image descriptor if not self.args.tags: self.args.tags = generator.get_tags() if 'build' in self.args.commands: params = {'user': self.args.build_osbs_user, 'nowait': self.args.build_osbs_nowait, 'stage': self.args.build_osbs_stage, 'release': self.args.build_osbs_release, 'tags': self.args.tags, 'pull': self.args.build_pull, 'redhat': tools.cfg['common']['redhat'], 'target': self.args.build_osbs_target } builder = Builder(self.args.build_engine, self.args.target, params) builder.prepare(generator.image) builder.build() if 'test' in self.args.commands: test_tags = [generator.get_tags()[0]] # if wip is specifed set tags to @wip if self.args.test_wip: test_tags = ['@wip'] # at first we collect tests tc = TestCollector(os.path.dirname(self.args.descriptor), self.args.target) # we run the test only if we collect any if tc.collect(generator.image.get('schema_version'), self.args.test_steps_url): runner = TestRunner(self.args.target) runner.run(self.args.tags[0], test_tags) else: logger.warning("No test collected, test can't be run.") logger.info("Finished!") sys.exit(0) except KeyboardInterrupt as e: pass except CekitError as e: if self.args.verbose: logger.exception(e) else: logger.error(str(e)) sys.exit(1)