[Buildbot-devel] single builder run with multiple trigger requests

Boris Savelev boris.savelev at gmail.com
Tue Jun 21 08:56:18 UTC 2011


> What I do:
> I create builder project1_source that generate tarball from git.
> I create blocker step for project1_linux_x86 that depends on git step
> of project1_source builder.
> I write buildsMatch for blocker step, that check all builds of builder
> project1_source and compare 'uniqnumber' from project1_linux_x86
> build.
> All is fine, but I don't know how to run builder project1_source if no
> any match builds of project1_source found.
>
> The question is:
> I have builder object and property dict. How I can force builder with
> properties from blocker step.
>
class looks like this (some copy-paste from original class)

import buildbot.steps.blocker
class DwBlocker(buildbot.steps.blocker.Blocker):

    VALID_IDLE_POLICIES =
buildbot.steps.blocker.Blocker.VALID_IDLE_POLICIES + ("run",)

    def _getBuildStatus(self, botmaster, builderName):
        try:
            builder = botmaster.builders[builderName]
        except KeyError:
            raise BadStepError(
                "no builder named %r" % builderName)

        myBuildStatus = self.build.getStatus()
        builderStatus = builder.builder_status
        matchingBuild = None

        all_builds = (builderStatus.buildCache.values() +
                      builderStatus.getCurrentBuilds())

        for buildStatus in all_builds:
            if self.buildsMatch(myBuildStatus, buildStatus):
                matchingBuild = buildStatus
                break

        if matchingBuild is None:
            msg = "no matching builds found in builder %r" % builderName
            if self.idlePolicy == "error":
                raise BadStepError(msg + " (is it idle?)")
            elif self.idlePolicy == "ignore":
                # don't hang around waiting (assume the build has finished)
                self._log(msg + ": skipping it")
                return None
            elif self.idlePolicy == "block":
                self._log(msg + ": will block until it starts a build")
                self._blocking_builders.add(builderStatus)
                return None
            elif self.idlePolicy == "run":
                self._log(msg + ": start build for break the block")

        self._log("found builder %r: %r", builderName, builder)
        return matchingBuild

    def buildsMatch(self, buildStatus1, buildStatus2):
        return \
            buildStatus1.getProperties().has_key('uniquebuildnumber') and \
            buildStatus2.getProperties().has_key('uniquebuildnumber') and \
            buildStatus1.getProperties()['uniquebuildnumber'] == \
            buildStatus2.getProperties()['uniquebuildnumber']


This part need some more code-)
            elif self.idlePolicy == "run":
                self._log(msg + ": start build for break the block")

Code that start builder 'builderName` with props
'{'uniquebuildnumber':
myBuildStatus.getProperties()['uniquebuildnumber']}`

-- 
Boris




More information about the devel mailing list