Limit GithubStatus to certain builders in BuildBot

Written by Johannes on February 16, 2015 Categories: Buildbot, Continuous Integration, git, github, Python

Your ads will be inserted here by

Easy AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

We use Github in combination with BuildBot for our continuous integration setup. With this, the Github commit status API comes incredibly handy. We use it to notify Github whether the tests pass or fail for any incoming pull request. Unfortunately the Buildbot Github status target is incredibly chatty and tries to push status updates for any incoming changes on Github. We run multiple sequential and concurrent builds for each commit. So this is something we do not want, mainly because these status notifications will spam our developer chat. Having a list of 5 build status updates for a single commit spam your chat and mailing list is not fun.

The mailing status notifier can be limited using a category filter, unfortunately the GithubStatus doesn’t provide this feature. But we can easily subclass it and reimplement the feature. Note that GitHubStatus is an old style class, so we need to explicitly call the parent constructor and pass self.

from buildbot.status.github import GitHubStatus</code>
 
class FilteredGitHubStatus(GitHubStatus):
    def __init__(self, tags=None, *args, **kwargs):
        self.tags = tags
        GitHubStatus.__init__(self, *args, **kwargs)
 
    def builderAdded(self, name, builder):
        # only subscribe to builders we are interested in
        if self.tags is not None and builder.category not in self.tags:
            return None
 
        return self # subscribe to this builder
 
sha = Interpolate("%(src::revision)s")
gs = FilteredGitHubStatus(
    token=github_token,
    repoOwner="myghaccount",
    repoName="myrepo",
    sha=sha,
    tags=["pullrequest"],
    startDescription='Build started.',
    endDescription='Build done.')
 
c["status"].append(gs)
 
pull_request_build = BuilderConfig(
    name="pullrequest-build",
    slavenames=CONTROL_SLAVES,
    category="pullrequest",
    factory=BuildFactory([ShellCommand(command=["echo", '"Hello world"'])),
)
No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre user="" computer="" escaped="">