def get_web(): from buildbot.status import html from buildbot.status.web import authz, auth import users users = users.get_users() authz_cfg = authz.Authz(auth=auth.BasicAuth(users), view=True, forceBuild='auth', forceAllBuilds='auth', pingBuilder='auth', gracefulShutdown=False, pauseSlave='auth', stopBuild='auth', stopAllBuilds='auth', cancelPendingBuild='auth', cancelAllPendingBuilds='auth', stopChange='auth', cleanShutdown=False, showUsersPage='auth') return html.WebStatus(http_port="tcp:8010:interface=127.0.0.1", authz=authz_cfg, change_hook_dialects={ 'base': True, 'github': {} }, change_hook_auth=['file:changehook.passwd'])
from buildstatusimage import BuildStatusImageResource # using simplejson instead of json since Twisted wants ascii instead of unicode import simplejson as json status = [] # Load users from external file, see users.json.sample users = [] for user in json.load(open("users.json")): users.append((user['username'], user['password'])) authz_cfg = authz.Authz( # change any of these to True to enable; see the manual for more # options auth=auth.BasicAuth(users), gracefulShutdown=False, forceBuild='auth', # use this to test your slave once it is set up forceAllBuilds='auth', pingBuilder='auth', stopBuild='auth', stopAllBuilds='auth', cancelPendingBuild='auth', ) class WebStatus(html.WebStatus): def setupUsualPages(self, numbuilds, num_events, num_events_max): html.WebStatus.setupUsualPages(self, numbuilds, num_events, num_events_max) self.putChild("buildstatusimage", BuildStatusImageResource())
####### 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 from buildbot.status import words authz_cfg=authz.Authz( # change any of these to True to enable; see the manual for more # options auth=auth.BasicAuth([("forkk", "password")]), gracefulShutdown = False, forceBuild = 'auth', # use this to test your slave once it is set up forceAllBuilds = False, pingBuilder = False, stopBuild = False, stopAllBuilds = False, cancelPendingBuild = False, ) c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg, change_hook_dialects={"github": True})) ####### PROJECT IDENTITY # the 'title' string will appear at the top of this buildbot
def __init__(self, name, homepage, secretsfile="~/myconfig.json", *args, **kwargs): dict.__init__(self, *args, **kwargs) # Find the directory containing this .py file thisfile = __file__ thisfile = thisfile.replace(".pyc", ".py") try: thisfile = os.readlink(thisfile) except: pass dir = os.path.join(os.path.dirname(thisfile)) masterjson = json.load(open(os.path.join(dir, "master.json"))) # Lots of unrelated stuff is grouped here simply because buildbot needs it all. # See e.g. https://github.com/buildbot/buildbot/blob/master/master/buildbot/scripts/sample.cfg # for a simple hard-coded linear example of what buildbot needs set. # FIXME: find a more readable way to organize this # Since we need to process tags, disable merging for the moment # Later we can make this smarter and disable merging just changes # which are at tags, or enable merging just on builders that are # way too slow and don't mind missing a tag self['mergeRequests'] = False # PORT NUMBERS # It's hard to keep port numbers straight for multiple projects, # so let's assign each project a slot number, # and use 8010 + slotnum for the http port, # 9010 + slotnum for the slave port, etc. # FIXME: get slot from masterjson slot = 0 self.__http_port = 8010 + slot self['slavePortnum'] = 9010 + slot # SECRETS # Avoid checking secrets into git by keeping them in a json file. try: s = json.load(open(os.path.expanduser(secretsfile))) self.__auth = auth.BasicAuth([ (s["webuser"].encode('ascii', 'ignore'), s["webpass"].encode('ascii', 'ignore')) ]) # For the moment, all slaves have same password self.slavepass = s["slavepass"].encode('ascii', 'ignore') except: exit( "%s must be a json file containing webuser, webpass, and slavepass; ascii only, no commas in quotes" % secretsfile) # STATUS TARGETS self['status'] = [] authz_cfg = authz.Authz( # change any of these to True to enable; see the manual for more # options auth=self.__auth, gracefulShutdown=False, forceBuild='auth', forceAllBuilds=True, pingBuilder=True, stopBuild=True, stopAllBuilds=True, cancelPendingBuild=True, ) # Need order_console_by_time for git or hg or any vcs that doesn't have numbered changesets self['status'].append( html.WebStatus(http_port=self.__http_port, authz=authz_cfg, order_console_by_time=True)) self['status'].append( MailNotifier(fromaddr="*****@*****.**", mode=('problem'), sendToInterestedUsers=True, extraRecipients=['*****@*****.**'])) # DB URL self['db'] = { # This specifies what database buildbot uses to store its state. # This default is ok for all but the largest installations. 'db_url': "sqlite:///state.sqlite", } # 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. # FIXME: get name and homepage from masterjson self['title'] = name self['titleURL'] = homepage # 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. self['buildbotURL'] = "http://" + socket.gethostname( ) + ":%d/" % self.__http_port # SLAVES self._os2slaves = {} self['slaves'] = [] slaveconfigs = masterjson["slaves"] for slaveconfig in slaveconfigs: sname = slaveconfig["name"].encode('ascii', 'ignore') sos = slaveconfig["os"].encode('ascii', 'ignore') # Restrict to a single build at a time because our buildshims # typically assume they have total control of machine, and use sudo apt-get, etc. with abandon. s = BuildSlave(sname, self.slavepass, max_builds=1) self['slaves'].append(s) if sos not in self._os2slaves: self._os2slaves[sos] = [] self._os2slaves[sos].append(sname) # These will be built up over the course of one or more calls to addSimpleProject self['change_source'] = [] self['builders'] = [] self['schedulers'] = [] # Righty-o, wire 'em all up for project in masterjson["projects"]: self.addSimpleProject( project["name"].encode('ascii', 'ignore'), project["category"].encode('ascii', 'ignore'), project["repourl"].encode('ascii', 'ignore'), project["builders"])
factory_weekly.addStep(get_changelog_step('weekly')) c['builders'].append( BuilderConfig(name="weekly", slavenames=[config.SLAVE_NAME], factory=factory_weekly)) ####### STATUS TARGETS c['status'] = [] from buildbot.status import html from buildbot.status.web import authz, auth authz_cfg = authz.Authz( auth=auth.BasicAuth([(config.AUTH_USER, config.AUTH_PSW)]), gracefulShutdown=False, forceBuild='auth', forceAllBuilds=False, pingBuilder=False, stopBuild=False, stopAllBuilds=False, cancelPendingBuild=False, ) c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) ####### MAIL NOTIFIER from buildbot.status.mail import MailNotifier from buildbot.status.builder import Results
################################# BUILDERS ################################# win_Server_Business_build_dir = "build_win_Server_Business_dir" b_win_Server_Business = { 'name' : 'win_Server_Business', 'slavename' : 'Win_Server_Business', 'builddir' : win_Server_Business_build_dir, 'slavebuilddir' : win_Server_Business_build_dir, 'locks' : [db_lock.access("exclusive")], 'factory' : f_win_Server_Business} ################################# STATUS TARGETS ################################# authz_cfg=authz.Authz( # change any of these to True to enable; see the manual for more # options auth=auth.BasicAuth([('admin', 'admin_123456')]), gracefulShutdown = False, forceBuild = 'auth', # use this to test your slave once it is set up forceAllBuilds = False, pingBuilder = False, stopBuild = 'auth', stopAllBuilds = False, cancelPendingBuild = 'auth', ) ################################# PROJECT MailNotifier ################################# win_Server_Business_mail = MailNotifier( fromaddr="*****@*****.**", sendToInterestedUsers=True, lookup = "goland.cn", mode='failing',
description="stopping containers", descriptionDone="stopped", workdir=BUILDSLAVE_BUILD_PATH + '/' + PROJECT_TEST_FOLDER, command=["docker-compose", "stop"])) BUILDBOT_FACTORY_FOR_TEST.addStep( steps.ShellCommand(name="remove containers", description="removing containers", descriptionDone="removed", workdir=BUILDSLAVE_BUILD_PATH + '/' + PROJECT_TEST_FOLDER, command=["docker-compose", "rm", "-f"])) # ------ # status # ------ BUILDBOT_MASTER_AUTHZ_CFG = authz.Authz( # change any of these to True to enable; see the manual for more # options auth=auth.BasicAuth([(BUILDBOT_MASTER_AUTH_ACCOUNT, BUILDBOT_MASTER_AUTH_PASS)]), gracefulShutdown=False, forceBuild='auth', # use this to test your slave once it is set up forceAllBuilds='auth', # ..or this pingBuilder=False, stopBuild=False, stopAllBuilds=False, cancelPendingBuild=False, )
"generator": "NMake Makefiles", "extra_arguments": p_extra_arguments })) ####### 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. from buildbot.status import html from buildbot.status.web import authz, auth from irc import ExtendedIRC from nightly import ShutdownIdleSlaves authz_cfg = authz.Authz(auth=auth.BasicAuth([("%%WEB-USERNAME%%", "%%WEB-PASSWORD%%")]), default_action='auth') status_web = html.WebStatus(authz=authz_cfg, http_port=8010) status_irc = ExtendedIRC( host="irc.dairc.net", port=6697, useSSL=True, useRevisions=True, nick="eA-BuildBot", password="******", channels=["#Athena"], notify_events={ #'started': 1, #'finished': 1, #'success': 1, 'failure': 1,
c['status'] = [] from buildbot.status import html from buildbot.status.web import authz, auth authz_cfg=authz.Authz( #change to true to enable function auth=auth.BasicAuth([("pyflakes", "pyflakes")]), gracefulShutdown = False, forceBuild = 'auth', #use this to test slave pingBuild = False, stopBuild = False, stopAllBuilds = False, cancelPendingBuild = False ) c['status'].append(html.WebStatus(http_port=8010, authz_cfg)) from buildbot.scheduler import Try_Userpass c['schedulers'].append(Try_Userpass( name = 'try' builderNames=['runtests'], port=5555, userpass=[('sampleuser', 'samplepass')]))
return imgcontent class NimBuildStatus(html.WebStatus): def setupUsualPages(self, numbuilds, num_events, num_events_max): File.contentTypes[".db"] = "application/x-sqlite3" html.WebStatus.setupUsualPages(self, numbuilds, num_events, num_events_max) self.putChild("buildstatusimage", StatusImageResource()) authz_cfg = authz.Authz( # change any of these to True to enable; see the manual for more # options auth=auth.BasicAuth(user_credentials), gracefulShutdown=False, forceBuild='auth', forceAllBuilds='auth', pingBuilder=False, stopBuild='auth', stopAllBuilds='auth', cancelPendingBuild='auth', ) c['status'].append(NimBuildStatus(http_port=8010, authz=authz_cfg)) # 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.