def UploadArtifact(self, path, archive=True, strict=True): """Upload generated artifact to Google Storage. Args: path: Path of local file to upload to Google Storage if |archive| is True. Otherwise, this is the name of the file in self.archive_path. archive: Whether to automatically copy files to the archive dir. strict: Whether to treat upload errors as fatal. """ filename = path if archive: filename = commands.ArchiveFile(path, self.archive_path) upload_urls = self._GetUploadUrls(filename) try: commands.UploadArchivedFile(self.archive_path, upload_urls, filename, self._run.debug, update_list=True, acl=self.acl) except failures_lib.GSUploadFailure as e: logging.PrintBuildbotStepText('Upload failed') if e.HasFatalFailure(whitelist=[ gs.GSContextException, timeout_util.TimeoutError ]): raise elif strict: raise else: # Treat gsutil flake as a warning if it's the only problem. self._HandleExceptionAsWarning(sys.exc_info())
def ArchiveHWQual(): """Build and archive the HWQual images.""" # TODO(petermayo): This logic needs to be exported from the BuildTargets # stage rather than copied/re-evaluated here. # TODO(mtennant): Make this autotest_built concept into a run param. autotest_built = ( self._run.options.tests and config['upload_hw_test_artifacts']) if config['hwqual'] and autotest_built: # Build the full autotest tarball for hwqual image. We don't upload it, # as it's fairly large and only needed by the hwqual tarball. logging.info('Archiving full autotest tarball locally ...') logging.info('Running commands.BuildFullAutotestTarball') tarball = commands.BuildFullAutotestTarball( self._build_root, self._current_board, image_dir) self.board_runattrs.SetParallel('autotest_tarball_generated', True) logging.info('Running commands.ArchiveFile') commands.ArchiveFile(tarball, archive_path) # Build hwqual image and upload to Google Storage. hwqual_name = 'chromeos-hwqual-%s-%s' % (board, self.version) logging.info('Running commands.ArchiveHWQual') filename = commands.ArchiveHWQual(buildroot, hwqual_name, archive_path, image_dir) self._release_upload_queue.put([filename]) else: self.board_runattrs.SetParallel('autotest_tarball_generated', True)