def BaseFactory(self, recipe, factory_properties=None, triggers=None, timeout=1200, max_time=None): """The primary input for the factory is the |recipe|, which specifies the name of a recipe file to search for. The recipe file will fill in the rest of the |factory_properties|. This setup allows for major changes to factory properties to occur on slave-side without master restarts. NOTE: Please be very discerning with what |factory_properties| you pass to this method. Ideally, you will pass none, and that will be sufficient in the vast majority of cases. Think very carefully before adding any |factory_properties| here, as changing them will require a master restart. |timeout| refers to the maximum number of seconds a step should be allowed to run without output. After no output for |timeout| seconds, the step is forcibly killed. |max_time| refers to the maximum number of seconds a step should be allowed to run, regardless of output. After |max_time| seconds, the step is forcibly killed. """ factory_properties = factory_properties or {} factory_properties.update({'recipe': recipe}) self._factory_properties = factory_properties factory = BuildFactory() cmd_obj = annotator_commands.AnnotatorCommands(factory) cmd_obj.AddAnnotatedScript( factory_properties, timeout=timeout, max_time=max_time) for t in (triggers or []): factory.addStep(commands.CreateTriggerStep( t, trigger_copy_properties=['swarm_hashes'])) return factory
def TriggerFactory(self, factory, slave_type, factory_properties): """Add post steps on a build created by BuildFactory.""" # Trigger any schedulers waiting on the build to complete. factory_properties = factory_properties or {} if factory_properties.get('trigger') is None: return trigger_name = factory_properties.get('trigger') # Propagate properties to the children if this is set in the factory. trigger_properties = factory_properties.get('trigger_properties', []) factory.addStep(commands.CreateTriggerStep( trigger_name=trigger_name, trigger_copy_properties=trigger_properties))
def AddTrigger(self, trigger_who): self._factory.addStep(commands.CreateTriggerStep( trigger_name=trigger_who, trigger_drop_properties=['parent_cr_revision'], trigger_set_properties={ 'triggered_by_buildername': WithProperties( '%(buildername:-None)s'), 'triggered_by_buildnumber': WithProperties( '%(buildnumber:-None)s'), 'triggered_by_slavename': WithProperties( '%(slavename:-None)s'), 'triggered_by_revision': WithProperties( '%(revision:-None)s'), }, waitForFinish=True))
def BaseFactory(self, recipe=None, factory_properties=None, triggers=None, timeout=2400, max_time=None): """The primary input for the factory is the |recipe|, which specifies the name of a recipe file to search for. The recipe file will fill in the rest of the |factory_properties|. This setup allows for major changes to factory properties to occur on slave-side without master restarts. NOTE: Please be very discerning with what |factory_properties| you pass to this method. Ideally, you will pass none, and that will be sufficient in the vast majority of cases. Think very carefully before adding any |factory_properties| here, as changing them will require a master restart. |recipe| is the name of the recipe to pass to annotated_run. If omitted, annotated_run will attempt to look up the recipe from builders.pyl in the master. |timeout| refers to the maximum number of seconds a build should be allowed to run without output. After no output for |timeout| seconds, the build is forcibly killed. |max_time| refers to the maximum number of seconds a build should be allowed to run, regardless of output. After |max_time| seconds, the build is forcibly killed. """ factory_properties = factory_properties or {} if recipe: factory_properties.update({'recipe': recipe}) self._factory_properties = factory_properties factory = BuildFactory(build_inherit_factory_properties=False) factory.properties.update(self._factory_properties, 'AnnotatorFactory') cmd_obj = annotator_commands.AnnotatorCommands( factory, active_master=self.active_master) runner = cmd_obj.PathJoin(cmd_obj.script_dir, 'annotated_run.py') cmd = [cmd_obj.python, '-u', runner, '--use-factory-properties-from-disk'] cmd = cmd_obj.AddB64GzBuildProperties(cmd) cmd_obj.AddAnnotatedScript(cmd, timeout=timeout, max_time=max_time) for t in triggers or []: factory.addStep(commands.CreateTriggerStep( t, trigger_copy_properties=['swarm_hashes'])) return factory
def RemoteRunFactory(active_master, repository, recipe, revision=None, factory_properties=None, timeout=2400, max_time=None, triggers=None, use_gitiles=False): """Returns buildbot build factory which runs recipes using recipe engine's remote_run command. |active_master| is config_bootstrap.Master's subclass from master's master_site_config.py . |repository| is the URL of repository containing recipe to run. |recipe| is the name of the recipe to run. |revision| is the revision to use for repo checkout (by default we use latest revision). Must be a commit hash or a fully-qualified ref. |factory_properties| is a dictionary of default build properties. |timeout| refers to the maximum number of seconds a build should be allowed to run without output. After no output for |timeout| seconds, the build is forcibly killed. |max_time| refers to the maximum number of seconds a build should be allowed to run, regardless of output. After |max_time| seconds, the build is forcibly killed. |triggers| is a list of builders on the same master to trigger after the build. |use_gitiles| enables a Gitiles-specific way to fetch the repo; it's more efficient for large repos. """ revision = revision or 'refs/heads/master' if isinstance(revision, basestring): assert re.match('^([a-z0-9]{40}|refs/.+)$', revision) factory_properties = factory_properties or {} # This is useful e.g. for botmap updater to easily extract info about builder. factory_properties.update({ 'recipe': recipe, 'recipe_repository': repository, 'use_gitiles': use_gitiles, }) factory = BuildFactory(build_inherit_factory_properties=False) factory.properties.update(factory_properties, 'RemoteRunFactory') cmd_obj = annotator_commands.AnnotatorCommands(factory, active_master=active_master) runner = cmd_obj.PathJoin(cmd_obj.script_dir, 'remote_run.py') cmd = [ cmd_obj.python, '-u', runner, '--repository', repository, '--revision', revision, '--recipe', recipe, ] if use_gitiles: cmd.append('--use-gitiles') cmd = cmd_obj.AddB64GzBuildProperties(cmd) cmd = cmd_obj.AddB64GzFactoryProperties(factory_properties, cmd) cmd_obj.AddAnnotatedScript(cmd, timeout=timeout, max_time=max_time) for t in triggers or []: factory.addStep( commands.CreateTriggerStep( t, trigger_copy_properties=['swarm_hashes'])) return factory
def RemoteRunFactory(active_master, repository, recipe, revision='origin/master', factory_properties=None, timeout=2400, max_time=None, triggers=None): """Returns buildbot build factory which runs recipes using recipe engine's remote_run command. |active_master| is config_bootstrap.Master's subclass from master's master_site_config.py . |repository| is the URL of repository containing recipe to run. |recipe| is the name of the recipe to run. |revision| is the revision to use for repo checkout (by default we use latest revision). |factory_properties| is a dictionary of default build properties. |timeout| refers to the maximum number of seconds a build should be allowed to run without output. After no output for |timeout| seconds, the build is forcibly killed. |max_time| refers to the maximum number of seconds a build should be allowed to run, regardless of output. After |max_time| seconds, the build is forcibly killed. |triggers| is a list of builders on the same master to trigger after the build. """ factory_properties = factory_properties or {} # This is useful e.g. for botmap updater to easily extract info about builder. factory_properties.update({'recipe': recipe}) factory = BuildFactory(build_inherit_factory_properties=False) factory.properties.update(factory_properties, 'RemoteRunFactory') cmd_obj = annotator_commands.AnnotatorCommands(factory, active_master=active_master) runner = cmd_obj.PathJoin(cmd_obj.script_dir, 'remote_run.py') cmd = [ cmd_obj.python, '-u', runner, '--repository', repository, '--revision', revision, '--recipe', recipe, ] cmd = cmd_obj.AddB64GzBuildProperties(cmd) cmd = cmd_obj.AddB64GzFactoryProperties(factory_properties, cmd) cmd_obj.AddAnnotatedScript(cmd, timeout=timeout, max_time=max_time) for t in triggers or []: factory.addStep( commands.CreateTriggerStep( t, trigger_copy_properties=['swarm_hashes'])) return factory