<div dir="ltr">Is there any guidance or examples for how a nextBuild callback should be written?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 4, 2017 at 6:33 PM, Chris Spencer <span dir="ltr"><<a href="mailto:chrisspen@gmail.com" target="_blank">chrisspen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>What would the fix be? I tried this:<br><br>    def nextBuild(bldr, requests):<br>        <br>        def has_one(sources, branch):<br>            for key, data in sources:<br>                if data.branch == branch:<br>                    return True<br>            return False<br>        <br>        for r in requests:<br>            if has_one(r.sources, 'master'):<span class=""><br>                # Master always comes first.<br>                return r<br></span>            elif has_one(r.sources, 'staging'):<span class=""><br>                # Ignore staging until the end.<br>                continue<br>            else:<br>                # Otherwise, do the first build we see.<br>                return r<br>        return requests[0]<br><br>    c['builders'] = []<br>    c['builders'].append(<br>        util.BuilderConfig(<br>            name="runtests",<br>            workernames=["example-worker"]<wbr>,<br>            collapseRequests=True,<br>            nextBuild=nextBuild,<br>            factory=factory))<br><br></span></div>but that caused it to stop running all builds.<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 3, 2017 at 2:52 PM, Pierre Tardy <span dir="ltr"><<a href="mailto:tardyp@gmail.com" target="_blank">tardyp@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Chris,<div>Since buildbot nine, a buildrequest can have several sourcestamps, because it can be collapsed.</div><div>So there is no source attribute anymore, but a sources attribute, as per source code:</div><div><a href="https://github.com/buildbot/buildbot/blob/master/master/buildbot/process/buildrequest.py#L175" target="_blank">https://github.com/buildbot/bu<wbr>ildbot/blob/master/master/buil<wbr>dbot/process/buildrequest.py#<wbr>L175</a><br></div><div><br></div><div>Can submit a documentation fix for this bug you found?</div><div><br></div><div>Thanks</div><div>Pierre</div></div><br><div class="gmail_quote"><div><div class="m_-7949658197253217390h5"><div dir="ltr">On Mon, Apr 3, 2017 at 7:45 PM Chris Spencer <<a href="mailto:chrisspen@gmail.com" target="_blank">chrisspen@gmail.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-7949658197253217390h5"><div dir="ltr" class="m_-7949658197253217390m_6678552406460077819gmail_msg"><div class="m_-7949658197253217390m_6678552406460077819gmail_msg"><div class="m_-7949658197253217390m_6678552406460077819gmail_msg"><div class="m_-7949658197253217390m_6678552406460077819gmail_msg">I'm trying to create a build priority function, as outlined at <a href="http://docs.buildbot.net/latest/manual/customization.html#build-priority-functions" class="m_-7949658197253217390m_6678552406460077819gmail_msg" target="_blank">http://docs.buildbot.net/lates<wbr>t/manual/customization.html#<wbr>build-priority-functions</a>, to ensure all non-staging branches are run first.<br class="m_-7949658197253217390m_6678552406460077819gmail_msg"><br class="m_-7949658197253217390m_6678552406460077819gmail_msg"></div>My code looks like:<br class="m_-7949658197253217390m_6678552406460077819gmail_msg"><br class="m_-7949658197253217390m_6678552406460077819gmail_msg">    def nextBuild(bldr, requests):<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">        for r in requests:<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">            if r.source.branch == 'master':<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">                # Master always comes first.<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">                return r<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">            elif r.source.branch == 'staging':<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">                # Ignore staging until the end.<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">                continue<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">            else:<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">                # Otherwise, do the first build we see.<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">                return r<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">        return requests[0]<br class="m_-7949658197253217390m_6678552406460077819gmail_msg"><br class="m_-7949658197253217390m_6678552406460077819gmail_msg">    c['builders'] = []<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">    c['builders'].append(<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">        util.BuilderConfig(name="runte<wbr>sts",<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">            workernames=["example-worker"]<wbr>,<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">            collapseRequests=True,<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">            nextBuild=nextBuild,<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">            factory=factory))<br class="m_-7949658197253217390m_6678552406460077819gmail_msg"><br class="m_-7949658197253217390m_6678552406460077819gmail_msg"></div>However, this has stopped all builds from running, with the logs showing:<br class="m_-7949658197253217390m_6678552406460077819gmail_msg"><br class="m_-7949658197253217390m_6678552406460077819gmail_msg">    File "/usr/local/myproject/.env/loc<wbr>al/lib/python2.7/site-packages<wbr>/buildbot/process/buildrequest<wbr>distributor.py", line 237, in _getNextUnclaimedBuildRequest<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">        nextBreq = yield self.nextBuild(self.bldr, breqs)<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">    File "/usr/local/myproject/src/buil<wbr>dbot/master/master.cfg", line 130, in nextBuild<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">        if r.source.branch == 'master':<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">    exceptions.AttributeError: 'BuildRequest' object has no attribute 'source'<br class="m_-7949658197253217390m_6678552406460077819gmail_msg"><br class="m_-7949658197253217390m_6678552406460077819gmail_msg"></div>Why is the BuildRequest object missing the source attribute, as referred to in the documentation? Is the documentation incorrect?<br class="m_-7949658197253217390m_6678552406460077819gmail_msg"></div></div></div>
______________________________<wbr>_________________<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">
users mailing list<br class="m_-7949658197253217390m_6678552406460077819gmail_msg">
<a href="mailto:users@buildbot.net" class="m_-7949658197253217390m_6678552406460077819gmail_msg" target="_blank">users@buildbot.net</a><br class="m_-7949658197253217390m_6678552406460077819gmail_msg">
<a href="https://lists.buildbot.net/mailman/listinfo/users" rel="noreferrer" class="m_-7949658197253217390m_6678552406460077819gmail_msg" target="_blank">https://lists.buildbot.net/mai<wbr>lman/listinfo/users</a></blockquote></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>