/ status.py
status.py
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 4 # ###### STATUS TARGETS 5 6 # 'status' is a list of Status Targets. The results of each build will be 7 # pushed to these targets. buildbot/status/*.py has a variety to choose from, 8 # including web pages, email senders, and IRC bots. 9 10 from buildbot.status import html 11 from buildbot.status import words 12 from buildbot.status.web import authz, auth 13 from buildbot.status.github import GitHubStatus 14 from buildbot.process.properties import Interpolate 15 from buildstatusimage import BuildStatusImageResource 16 17 # using simplejson instead of json since Twisted wants ascii instead of unicode 18 import simplejson as json 19 20 status = [] 21 22 # Load users from external file, see users.json.sample 23 users = [] 24 for user in json.load(open("users.json")): 25 users.append((user['username'], user['password'])) 26 27 authz_cfg = authz.Authz( 28 # change any of these to True to enable; see the manual for more 29 # options 30 auth=auth.BasicAuth(users), 31 gracefulShutdown=False, 32 forceBuild='auth', # use this to test your slave once it is set up 33 forceAllBuilds='auth', 34 pingBuilder='auth', 35 stopBuild='auth', 36 stopAllBuilds='auth', 37 cancelPendingBuild='auth', 38 ) 39 40 41 class WebStatus(html.WebStatus): 42 def setupUsualPages(self, numbuilds, num_events, num_events_max): 43 html.WebStatus.setupUsualPages(self, numbuilds, num_events, num_events_max) 44 self.putChild("buildstatusimage", BuildStatusImageResource()) 45 46 status.append(WebStatus( 47 # http_port="ssl:port=8443:privateKey=/etc/ssl/server.key:certKey=/etc/ssl/server.crt:extraCertChain=/etc/ssl/server.ca-bundle", 48 http_port=8080, 49 authz=authz_cfg, 50 change_hook_auth=["file:changehook.passwd"], 51 change_hook_dialects={'github': {}}, 52 order_console_by_time=True)) 53 54 55 # IRC bot 56 ircbot = json.load(open("ircbot.json")) 57 status.append(words.IRC(host=ircbot['server'], 58 nick=ircbot['nickname'], 59 password=ircbot['password'], 60 channels=ircbot['channels'], 61 notify_events={ 62 'successToException': 1, 63 'successToFailure': 1, 64 'failureToSuccess': 1, 65 'exceptionToSuccess': 1} 66 )) 67 68 69 # GitHub Status 70 tokens = json.load(open("tokens.json")) 71 for repo in tokens: 72 gs = GitHubStatus( 73 token=tokens[repo]["token"], 74 repoOwner=tokens[repo]["owner"], 75 repoName=repo, 76 sha=Interpolate("%(src:" + repo + ":revision)s"), 77 startDescription='DEV build started.', 78 endDescription='DEV build done.') 79 status.append(gs)