import os from buildbot.buildslave import BuildSlave from buildbot.schedulers.forcesched import ForceScheduler from buildbot.schedulers.basic import SingleBranchScheduler from buildbot.changes import filter from buildbot.config import BuilderConfig from buildbot.process.factory import BuildFactory from buildbot.steps.shell import ShellCommand from buildbot.status import html from buildbot.status.web import authz, auth PORT_WEB = 80 # Buildbot webserver port PORT_GITHUB = 8011 # Buildbot github hook port PORT_MASTER = 9989 # Port where buildbot master listen buildworkers TEST_USER = 'buildbot' # Credential to authenticate build triggers TEST_PWD = 'docker' # Credential to authenticate build triggers BUILDER_NAME = 'docker' BUILDPASSWORD = 'pass-docker' # Credential to authenticate buildworkers GITHUB_DOCKER = "github.com/dotcloud/docker" DOCKER_PATH = "/data/docker" BUILDER_PATH = "/data/buildbot/slave/{0}/build".format(BUILDER_NAME) DOCKER_BUILD_PATH = BUILDER_PATH + '/src/github.com/dotcloud/docker' c = BuildmasterConfig = {} c['title'] = "Docker" c['titleURL'] = "waterfall" c['buildbotURL'] = "http://0.0.0.0:{0}/".format(PORT_WEB) c['db'] = {'db_url':"sqlite:///state.sqlite"} c['slaves'] = [BuildSlave('buildworker', BUILDPASSWORD)] c['slavePortnum'] = PORT_MASTER c['schedulers'] = [ForceScheduler(name='trigger',builderNames=[BUILDER_NAME])] c['schedulers'].append(SingleBranchScheduler(name="all", change_filter=filter.ChangeFilter(branch='master'),treeStableTimer=None, builderNames=[BUILDER_NAME])) # Docker test command test_cmd = ("cd /tmp; rm -rf {0}; export GOPATH={0}; go get -d {1}; cd {2}; " "go test").format(BUILDER_PATH,GITHUB_DOCKER,DOCKER_BUILD_PATH) # Builder factory = BuildFactory() factory.addStep(ShellCommand(description='Docker',logEnviron=False, usePTY=True,command=test_cmd)) c['builders'] = [BuilderConfig(name=BUILDER_NAME,slavenames=['buildworker'], factory=factory)] # Status authz_cfg=authz.Authz(auth=auth.BasicAuth([(TEST_USER,TEST_PWD)]), forceBuild='auth') c['status'] = [html.WebStatus(http_port=PORT_WEB, authz=authz_cfg)] c['status'].append(html.WebStatus(http_port=PORT_GITHUB,allowForce=True, change_hook_dialects={ 'github' : True }))