Monthly Archives: July 2018

Buildbot custom BuildStep with renderables example

Custom buildsteps need to:
* Accept and take any arguments in the __init__ method
* Call the parent class’ __init__ method
* Declare any attributes that need to be rendered in renderables attribute (this happens after __init__ and before run
* Do the action in the run method and return SUCCESS from this method

Here’s a simple example CustomStep designed to pass arguments directly to another class AnotherClass and call a method on the instance.

from buildbot.process.buildstep import BuildStep
from buildbot.process.results import SUCCESS

class CustomStep(BuildStep):
    name = 'customstep'
    description = 'Do the Thing'
    descriptionDone = 'Done the Thing'

    kwargs = None
    renderables = ['kwargs']

    rendered = True  # attributes are rendered

    def __init__(self, **kwargs):
        self.kwargs = kwargs
        super(CustomStep, self).__init__()

    def run(self):
        c = AnotherClass(**self.kwargs)
        return SUCCESS

And to run the step:

    'id': util.Property('id'),
    'image': util.Property('image'),
    'source': 'someplace',
    'url': util.Interpolate("https://%(prop:branch)"),

If your build raises an exception on the new buildstep but gives no output, check the buildbot master logs. If you get an error TypeError: list indices must be integers, not NoneType with this line: stepsumm += u' (%s)' % Results[self.results] then make sure your run returns SUCCESS.