[Buildbot-devel] [SOLVED] Still have problems with schedulers passing wrong branches

Bailey, Darragh dbailey at hp.com
Mon Sep 7 14:16:00 UTC 2009




> -----Original Message-----
> From: Bailey, Darragh 
> Sent: 26 August 2009 14:13
> To: Gavin
> Cc: 'buildbot-devel list'
> Subject: Re: [Buildbot-devel] Still have problems with 
> schedulers passing wrongbranches

<snipage>

> Might help if I improve the problem definition:
> 
> I cannot find a way to have a build triggered by a commit on 
> a particular branch, be able to trigger (via a trigger step) 
> a build on a completely different branch.
> 
> The reason I'm using a trigger step is so that I can pass 
> some information via build properties to the triggered build.
> 
> The initial builds that I have each produce an iso. The build 
> they trigger then controls what is done with that iso, i.e. 
> digitally sign each package within the iso. This only works 
> with the most uptodate code on trunk, so whatever branch the 
> iso is generated from, the final step needs to use code from 
> the trunk.
> 
> --
> Regards,
> Darragh Bailey


I eventually settled on a solution for this. Basically it involved adding a custom triggerable scheduler to the master config file that permitted setting of the branch, which would override the SourceStamp branch coming from the triggering build.

It means that I can have commit driven builds on one branch trigger builds on a completely difference branch.

Not sure whether it's sufficiently useful for anyone else, but here's the code anyway:

from buildbot.scheduler import Triggerable
from buildbot.process.properties import Properties
from buildbot import buildset
class customTriggerable(Triggerable):
    """
    This scheduler is based on triggerable, but takes a branch for which the
    triggered builds will always use, rather than the branch from the original
    triggering build.
    """

    compare_attrs = ('name', 'builderNames', 'properties')

    def __init__(self, name, builderNames, properties={}, branch=None):
        Triggerable.__init__(self, name, builderNames, properties)
        self.branch = branch

    def trigger(self, ss, set_props=None):
        """
        Trigger this scheduler. Returns a deferred that will fire when the
        buildset is finished.
        """

        # properties for this buildset are composed of our own properties,
        # potentially overridden by anything from the triggering build
        props = Properties()
        props.updateFromProperties(self.properties)
        if set_props: props.updateFromProperties(set_props)

        # if this scheduler has a defined branch, override the one passed
        # in by the triggering build
        if self.branch != None:
            ss.branch = self.branch

        bs = buildset.BuildSet(self.builderNames, ss, properties=props)
        d = bs.waitUntilFinished()
        self.submitBuildSet(bs)
        return d


--
Regards,
Darragh Bailey

Systems Software Engineer
Hewlett Packard Galway Ltd.

Postal Address:    Hewlett Packard Galway Limited, Ballybrit Business Park, Galway
Registered Office: Hewlett Packard Galway Limited, 63-74 Sir John Rogerson's Quay Dublin 2
Registered Number: 361933 





More information about the devel mailing list