[devel at bb.net] Accessing Properties inside step's constructor

Aakash Jain aj355 at cornell.edu
Thu Mar 15 14:42:01 UTC 2018


Hi,


I have a Buildbot instance which I am trying to use for both "buildbot try"
and Pull Requests. One difference between both of them is that "buildbot
try" set a property "patchid"  (--property=patchid="xyz123"). In a buildbot
checkout step, I am trying to differentiate whether it's a PR or "buildbot
try" patch. I am using following code:


class CheckOutGitSource(TrybotMixin, git.Git):

    def __init__(self, platform, **kwargs):

        kwargs['codebase'] = "my-repo-name"

        if *self.getProperty*('patchid', False):

            kwargs['codebase'] = ''

        super(CheckOutGitSource, self).__init__(**kwargs)



However, I am getting below exception in accessing self.getProperty()
(while initializing the factory). Am I correct in assuming that I am not
able to access getProperty() inside the constructor of the step, because
the step is not initialized yet and therefore the factory is not
initialized yet and so the properties can't be accessed in the step's
constructor?


What would be the right way to access the property and set the codebase
variable? Should I instead override start() method inside the step and set
self.codebase there?



 File "factories_unittest.py", line 193, in test_mac_debug

    factory = factories.GenericBuildFactory('mac', 'Debug')

  File "factories.py", line 105, in __init__

    super(GenericBuildFactory, self).__init__(platform, configuration,
**kwargs)

  File "factories.py", line 63, in __init__

    self.addSteps(self.CheckOutSourceSteps)

  File "factories.py", line 86, in CheckOutSourceSteps

    platform=self.platform))

  File "steps.py", line 439, in __init__

    if self.getProperty('patchid', False):

  File "/Library/Python/2.7/site-packages/buildbot/process/properties.py",
line 244, in getProperty

    props = IProperties(self)

  File "/Library/Python/2.7/site-packages/twisted/python/components.py",
line 122, in _hook

    return factory(ob)

  File "/Library/Python/2.7/site-packages/buildbot/process/buildstep.py",
line 938, in <lambda>

    lambda step: interfaces.IProperties(step.build),

TypeError: ('Could not adapt', None, <InterfaceClass
buildbot.interfaces.IProperties>)



Thanks

Aakash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildbot.net/pipermail/devel/attachments/20180315/1eff793e/attachment.html>


More information about the devel mailing list