def run(self, keep_going=False, buildstep_phase=False):
        """
        run all requested plugins

        :param keep_going: bool, whether to keep going after unexpected
                                 failure (only used for exit plugins)
        :param buildstep_phase: bool, when True remaining plugins will
                                not be executed after a plugin completes
                                (only used for build-step plugins)
        """
        failed_msgs = []
        plugin_successful = False
        plugin_response = None
        available_plugins = self.available_plugins
        for plugin in available_plugins:
            plugin_successful = False

            logger.debug("running plugin '%s'", plugin.name)
            start_time = datetime.datetime.now()

            plugin_response = None
            skip_response = False
            try:
                plugin_instance = self.create_instance_from_plugin(plugin.plugin_class,
                                                                   plugin.conf)
                self.save_plugin_timestamp(plugin.plugin_class.key, start_time)
                plugin_response = plugin_instance.run()
                plugin_successful = True
                if buildstep_phase:
                    assert isinstance(plugin_response, BuildResult)
                    if plugin_response.is_failed():
                        logger.error("Build step plugin %s failed: %s",
                                     plugin.plugin_class.key,
                                     plugin_response.fail_reason)
                        self.on_plugin_failed(plugin.plugin_class.key,
                                              plugin_response.fail_reason)
                        plugin_successful = False
                        self.plugins_results[plugin.plugin_class.key] = plugin_response
                        break

            except AutoRebuildCanceledException as ex:
                # if auto rebuild is canceled, then just reraise
                # NOTE: We need to catch and reraise explicitly, so that the below except clause
                #   doesn't catch this and make PluginFailedException out of it in the end
                #   (calling methods would then need to parse exception message to see if
                #   AutoRebuildCanceledException was raised here)
                raise
            except InappropriateBuildStepError:
                logger.debug('Build step %s is not appropriate', plugin.plugin_class.key)
                # don't put None, in results for InappropriateBuildStepError
                skip_response = True
                if not buildstep_phase:
                    raise
            except Exception as ex:
                msg = "plugin '%s' raised an exception: %r" % (plugin.plugin_class.key, ex)
                logger.debug(traceback.format_exc())
                if not plugin.is_allowed_to_fail:
                    self.on_plugin_failed(plugin.plugin_class.key, ex)

                if plugin.is_allowed_to_fail or keep_going:
                    logger.warning(msg)
                    logger.info("error is not fatal, continuing...")
                    if not plugin.is_allowed_to_fail:
                        failed_msgs.append(msg)
                else:
                    logger.error(msg)
                    raise PluginFailedException(msg)

                plugin_response = ex

            try:
                if start_time:
                    finish_time = datetime.datetime.now()
                    duration = finish_time - start_time
                    seconds = duration.total_seconds()
                    logger.debug("plugin '%s' finished in %ds", plugin.name, seconds)
                    self.save_plugin_duration(plugin.plugin_class.key, seconds)
            except Exception:
                logger.exception("failed to save plugin duration")

            if not skip_response:
                self.plugins_results[plugin.plugin_class.key] = plugin_response

            if plugin_successful and buildstep_phase:
                logger.debug('stopping further execution of plugins '
                             'after first successful plugin')
                break

        if len(failed_msgs) == 1:
            raise PluginFailedException(failed_msgs[0])
        elif len(failed_msgs) > 1:
            raise PluginFailedException("Multiple plugins raised an exception: " +
                                        str(failed_msgs))

        if not plugin_successful and buildstep_phase and not plugin_response:
            self.on_plugin_failed("BuildStepPlugin", "No appropriate build step")
            raise PluginFailedException("No appropriate build step")

        return self.plugins_results
def run ( self , keep_going = False , buildstep_phase = False ) : failed_msgs = [ ] plugin_successful = False plugin_response = None available_plugins = self . available_plugins for plugin in available_plugins : plugin_successful = False logger . debug ( "running plugin '%s'" , plugin . name ) start_time = datetime . datetime . now ( ) plugin_response = None skip_response = False try : plugin_instance = self . create_instance_from_plugin ( plugin . plugin_class , plugin . conf ) self . save_plugin_timestamp ( plugin . plugin_class . key , start_time ) plugin_response = plugin_instance . run ( ) plugin_successful = True if buildstep_phase : assert isinstance ( plugin_response , BuildResult ) if plugin_response . is_failed ( ) : logger . error ( "Build step plugin %s failed: %s" , plugin . plugin_class . key , plugin_response . fail_reason ) self . on_plugin_failed ( plugin . plugin_class . key , plugin_response . fail_reason ) plugin_successful = False self . plugins_results [ plugin . plugin_class . key ] = plugin_response break except AutoRebuildCanceledException as ex : raise except InappropriateBuildStepError : logger . debug ( 'Build step %s is not appropriate' , plugin . plugin_class . key ) skip_response = True if not buildstep_phase : raise except Exception as ex : msg = "plugin '%s' raised an exception: %r" % ( plugin . plugin_class . key , ex ) logger . debug ( traceback . format_exc ( ) ) if not plugin . is_allowed_to_fail : self . on_plugin_failed ( plugin . plugin_class . key , ex ) if plugin . is_allowed_to_fail or keep_going : logger . warning ( msg ) logger . info ( "error is not fatal, continuing..." ) if not plugin . is_allowed_to_fail : failed_msgs . append ( msg ) else : logger . error ( msg ) raise PluginFailedException ( msg ) plugin_response = ex try : if start_time : finish_time = datetime . datetime . now ( ) duration = finish_time - start_time seconds = duration . total_seconds ( ) logger . debug ( "plugin '%s' finished in %ds" , plugin . name , seconds ) self . save_plugin_duration ( plugin . plugin_class . key , seconds ) except Exception : logger . exception ( "failed to save plugin duration" ) if not skip_response : self . plugins_results [ plugin . plugin_class . key ] = plugin_response if plugin_successful and buildstep_phase : logger . debug ( 'stopping further execution of plugins ' 'after first successful plugin' ) break if len ( failed_msgs ) == 1 : raise PluginFailedException ( failed_msgs [ 0 ] ) elif len ( failed_msgs ) > 1 : raise PluginFailedException ( "Multiple plugins raised an exception: " + str ( failed_msgs ) ) if not plugin_successful and buildstep_phase and not plugin_response : self . on_plugin_failed ( "BuildStepPlugin" , "No appropriate build step" ) raise PluginFailedException ( "No appropriate build step" ) return self . plugins_results
run all requested plugins

        :param keep_going: bool, whether to keep going after unexpected
                                 failure (only used for exit plugins)
        :param buildstep_phase: bool, when True remaining plugins will
                                not be executed after a plugin completes
                                (only used for build-step plugins)