BuildStep classes have some extra equipment, because they are their own factories. Consider the use of a BuildStep in master.cfg:
f.addStep(MyStep(someopt="stuff", anotheropt=1))
This creates a single instance of class MyStep. However, Buildbot needs
a new object each time the step is executed. this is accomplished by storing
the information required to instantiate a new object in the factory
attribute. When the time comes to construct a new Build, BuildFactory consults
this attribute (via getStepFactory) and instantiates a new step object.
When writing a new step class, then, keep in mind are that you cannot do
anything "interesting" in the constructor – limit yourself to checking and
storing arguments. To ensure that these arguments are provided to any new
objects, call self.addFactoryArguments with any keyword arguments your
constructor needs.
Keep a **kwargs argument on the end of your options, and pass that up to
the parent class's constructor.
The whole thing looks like this:
class Frobinfy(LoggingBuildStep):
def __init__(self,
frob_what="frobee",
frob_how_many=None,
frob_how=None,
**kwargs)
# check
if frob_how_many is None:
raise TypeError("Frobinfy argument how_many is required")
# call parent
LoggingBuildStep.__init__(self, **kwargs)
# and record arguments for later
self.addFactoryArguments(
frob_what=frob_what,
frob_how_many=frob_how_many,
frob_how=frob_how)
class FastFrobnify(Frobnify):
def __init__(self,
speed=5,
**kwargs)
Frobnify.__init__(self, **kwargs)
self.addFactoryArguments(
speed=speed)