0

I have create custom buildstep in buildbot after running worker it is giving me following error.

builtins.AttributeError: 'MyStep' object has no attribute 'stopped'

Step is : custom_factory.addStep(MyStep(messages="Hi"))

If you have example how to write custom buildstep please share.

Viraj Wadate
  • 5,447
  • 1
  • 31
  • 29

1 Answers1

0

You're trying to access a member of your class 'MyStep' named 'stopped', whereas this member does not exist. One such access could be a field access like 'self.stopped'.

Shooting in the dark, here are simple custom steps I have in my bots, to provide you examples:

class _ClearPropertyStep(steps.BuildStep):
    """
        Step that clears a property
    """

    def __init__(self, prop, **kwargs):
        steps.BuildStep.__init__(self, **kwargs)
        assert prop is not None and len(prop) > 0
        self.property = prop

    @defer.inlineCallbacks
    def run(self):
        print("Clearing property " + self.property)
        self.setProperty(self.property, None, str(type(self)))
        yield defer.returnValue(SUCCESS)

Here's another one:

class _URLStep(steps.BuildStep):
    """
        Step whose only purpose is to show a description and an URL
    """

    renderables = steps.BuildStep.renderables + [
        'url_text',
        'url',
    ]

    def __init__(self, url_text, url, **kwargs):
        steps.BuildStep.__init__(self, **kwargs)
        assert url_text is not None
        self.url_text = url_text
        assert url is not None
        self.url = url

    @defer.inlineCallbacks
    def run(self):
        print("Setting URL: " + str(self.url))
        self.addURL(self.url_text, self.url)
        yield defer.returnValue(SUCCESS)
Clément Hurlin
  • 440
  • 3
  • 11