[Buildbot-devel] gerrit integration

Jason Edgecombe jason at rampaginggeek.com
Tue Jan 22 02:33:34 UTC 2013


Hi everyone,

I'm having trouble with the gerrit status module.  I've attached my 
buildmaster config.

I have two problems:
1. buildbot only starts a build after the change is merged.
2. the status updates don't make it back into gerrit.

Any help is appreciated.

Thanks,
Jason
-------------- next part --------------
# -*- python -*-
# ex: set syntax=python:

repo='ssh://buildbot@example.com:29418/buildbot-test'
gerrithost='example.com'
slavepassword='password'

# This is a sample buildmaster config file. It must be installed as
# 'master.cfg' in your buildmaster's base directory.

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
c = BuildmasterConfig = {}

####### BUILDSLAVES

# The 'slaves' list defines the set of recognized buildslaves. Each element is
# a BuildSlave object, specifying a unique slave name and password.  The same
# slave name and password must be configured on the slave.
from buildbot.buildslave import BuildSlave
c['slaves'] = []
c['slaves'].append(BuildSlave("mybuildslave", slavepassword))
c['slaves'].append(BuildSlave("mybuildslave2", slavepassword))

# 'slavePortnum' defines the TCP port to listen on for connections from slaves.
# This must match the value configured into the buildslaves (with their
# --master option)
c['slavePortnum'] = 9989

####### CHANGESOURCES

# the 'change_source' setting tells the buildmaster how it should find out
# about source code changes.

from buildbot.changes.gitpoller import GitPoller
c['change_source'] = []
#c['change_source'].append(GitPoller(
#        repo,
#        workdir='gitpoller-workdir', branch='master',
#        pollinterval=30))

#### gerrit changesource
from buildbot.changes.gerritchangesource import GerritChangeSource

c['change_source'].append(GerritChangeSource(gerrithost, 'buildbot'))


####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.  In this
# case, just kick off a 'testbuild' build

from buildbot.schedulers.basic import SingleBranchScheduler
from buildbot.schedulers.basic import AnyBranchScheduler
from buildbot.schedulers.forcesched import ForceScheduler
from buildbot.changes import filter
c['schedulers'] = []
c['schedulers'].append(AnyBranchScheduler(
                            name="all",
                            change_filter=filter.ChangeFilter(project='buildbot-test'),
                            treeStableTimer=None,
                            builderNames=["testbuild"]))


#c['schedulers'].append(SingleBranchScheduler(name="gerrit_scheduler_master", branch="master",
#                                 treeStableTimer=None,
#                                 builderNames=["testbuild"]))

c['schedulers'].append(ForceScheduler(
                            name="force",
                            builderNames=["testbuild"]))

####### BUILDERS

# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
# what steps, and which slaves can execute them.  Note that any particular build will
# only take place on one slave.

from buildbot.process.factory import BuildFactory
from buildbot.steps.source import Git
from buildbot.steps.shell import Compile
from buildbot.steps.shell import Configure
from buildbot.steps.shell import ShellCommand


factory = BuildFactory()
# check out the source
factory.addStep(Git(repourl=repo, mode='update'))
# run the tests (note that this will require that 'trial' is installed)
#factory.addStep(ShellCommand(command=["sleep","120"]))
#factory.addStep(ShellCommand(command=["git","clean","-X","-f","-e","!.buildbot-sourcedata"]))
#factory.addStep(Git(repourl=repourl, mode="update", ignore_ignores=True, retry=[60,60],timeout=3600))
#factory.addStep(ShellCommand(command=["git","gc","--auto"],timeout=3600))
factory.addStep(ShellCommand(command=["bash","regen.sh"],timeout=3600))
#factory.addStep(Configure(command=["./configure","--enable-checking","--enable-supergroups","--enable-namei-fileserver","--enable-pthreaded-ubik"]))
#factory.addStep(Compile(command=["make"]))
#factory.addStep(Compile(command=["make","dest"]))

from buildbot.config import BuilderConfig

c['builders'] = []
c['builders'].append(
    BuilderConfig(name="testbuild",
      slavenames=["mybuildslave","mybuildslave2"],
      factory=factory))

####### STATUS TARGETS

# 'status' is a list of Status Targets. The results of each build will be
# pushed to these targets. buildbot/status/*.py has a variety to choose from,
# including web pages, email senders, and IRC bots.

c['status'] = []

from buildbot.status import html
from buildbot.status.web import authz, auth

authz_cfg=authz.Authz(
    # change any of these to True to enable; see the manual for more
    # options
    auth=auth.BasicAuth([("testproject","password")]),
    gracefulShutdown = False,
    forceBuild = 'auth', # use this to test your slave once it is set up
    forceAllBuilds = True,
    pingBuilder = True,
    stopBuild = True,
    stopAllBuilds = True,
    cancelPendingBuild = True,
)
c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))


## gerrit
from buildbot.status.status_gerrit import GerritStatusPush
from buildbot.status.builder import Results, SUCCESS, RETRY

def gerritReviewCB(builderName, build, result, status, arg):
    if result == RETRY:
        return None, 0, 0

    message =  "Buildbot finished compiling your patchset\n"
    message += "on configuration: %s\n" % builderName
    message += "The result is: %s\n" % Results[result].upper()

    if arg:
        message += "\nFor more details visit:\n"
        message += status.getURLForThing(build) + "\n"

    # message, verified, reviewed
    return message, (result == SUCCESS or -1), 0

c['buildbotURL'] = 'http://localhost:8010/'
c['status'].append(GerritStatusPush(gerrithost, 'buildbot',
                                    reviewCB=gerritReviewCB,
                                    reviewArg=c['buildbotURL']))


####### PROJECT IDENTITY

# the 'title' string will appear at the top of this buildbot
# installation's html.WebStatus home page (linked to the
# 'titleURL') and is embedded in the title of the waterfall HTML page.

c['title'] = "OpenAFS"
c['titleURL'] = "http://www.openafs.org/"

# the 'buildbotURL' string should point to the location where the buildbot's
# internal web server (usually the html.WebStatus page) is visible. This
# typically uses the port number set in the Waterfall 'status' entry, but
# with an externally-visible host name which the buildbot cannot figure out
# without some help.

c['buildbotURL'] = "http://localhost:8010/"

####### DB URL

c['db'] = {
    # This specifies what database buildbot uses to store its state.  You can leave
    # this at its default for all but the largest installations.
    'db_url' : "sqlite:///state.sqlite",
}


More information about the devel mailing list