[users at bb.net] Build priority function failing due to attribute error

Chris Spencer chrisspen at gmail.com
Tue Apr 4 22:33:24 UTC 2017


What would the fix be? I tried this:

    def nextBuild(bldr, requests):

        def has_one(sources, branch):
            for key, data in sources:
                if data.branch == branch:
                    return True
            return False

        for r in requests:
            if has_one(r.sources, 'master'):
                # Master always comes first.
                return r
            elif has_one(r.sources, 'staging'):
                # Ignore staging until the end.
                continue
            else:
                # Otherwise, do the first build we see.
                return r
        return requests[0]

    c['builders'] = []
    c['builders'].append(
        util.BuilderConfig(
            name="runtests",
            workernames=["example-worker"],
            collapseRequests=True,
            nextBuild=nextBuild,
            factory=factory))

but that caused it to stop running all builds.

On Mon, Apr 3, 2017 at 2:52 PM, Pierre Tardy <tardyp at gmail.com> wrote:

> Hi Chris,
> Since buildbot nine, a buildrequest can have several sourcestamps, because
> it can be collapsed.
> So there is no source attribute anymore, but a sources attribute, as per
> source code:
> https://github.com/buildbot/buildbot/blob/master/master/
> buildbot/process/buildrequest.py#L175
>
> Can submit a documentation fix for this bug you found?
>
> Thanks
> Pierre
>
> On Mon, Apr 3, 2017 at 7:45 PM Chris Spencer <chrisspen at gmail.com> wrote:
>
>> I'm trying to create a build priority function, as outlined at
>> http://docs.buildbot.net/latest/manual/customization.
>> html#build-priority-functions, to ensure all non-staging branches are
>> run first.
>>
>> My code looks like:
>>
>>     def nextBuild(bldr, requests):
>>         for r in requests:
>>             if r.source.branch == 'master':
>>                 # Master always comes first.
>>                 return r
>>             elif r.source.branch == 'staging':
>>                 # Ignore staging until the end.
>>                 continue
>>             else:
>>                 # Otherwise, do the first build we see.
>>                 return r
>>         return requests[0]
>>
>>     c['builders'] = []
>>     c['builders'].append(
>>         util.BuilderConfig(name="runtests",
>>             workernames=["example-worker"],
>>             collapseRequests=True,
>>             nextBuild=nextBuild,
>>             factory=factory))
>>
>> However, this has stopped all builds from running, with the logs showing:
>>
>>     File "/usr/local/myproject/.env/local/lib/python2.7/site-
>> packages/buildbot/process/buildrequestdistributor.py", line 237, in
>> _getNextUnclaimedBuildRequest
>>         nextBreq = yield self.nextBuild(self.bldr, breqs)
>>     File "/usr/local/myproject/src/buildbot/master/master.cfg", line
>> 130, in nextBuild
>>         if r.source.branch == 'master':
>>     exceptions.AttributeError: 'BuildRequest' object has no attribute
>> 'source'
>>
>> Why is the BuildRequest object missing the source attribute, as referred
>> to in the documentation? Is the documentation incorrect?
>> _______________________________________________
>> users mailing list
>> users at buildbot.net
>> https://lists.buildbot.net/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildbot.net/pipermail/users/attachments/20170404/7874ed37/attachment.html>


More information about the users mailing list