我在运行worker之后在buildbot中创建了自定义buildstep,它给了我以下错误。
builtins.AttributeError:'MyStep'对象没有属性'stopped']
步骤为:custom_factory.addStep(MyStep(消息= “您好”))
如果您有如何编写自定义构建步骤的示例,请分享。
您正在尝试访问名为'stopped'的类'MyStep'的成员,而该成员不存在。这样的访问之一可能是诸如“ self.stopped”的字段访问。
在黑暗中射击,这是我在机器人中执行的简单自定义步骤,为您提供示例:
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)
这里是另一个:
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)