def testMail(self): basedir = "test_status_mail" os.mkdir(basedir) dest = os.environ.get("BUILDBOT_TEST_MAIL") if not dest: raise unittest.SkipTest( "define BUILDBOT_TEST_MAIL=dest to run this") mailer = mail.MailNotifier(fromaddr="*****@*****.**", addLogs=True, extraRecipients=[dest]) s = MyStatus() s.url = "project URL" mailer.status = s b1 = self.makeBuild(3, builder.SUCCESS) b1.testlogs = [ MyLog(basedir, 'compile', "Compile log here\n"), MyLog(basedir, 'test', "Test log here\nTest 4 failed\n"), ] print "sending mail to", dest d = mailer.buildFinished("builder1", b1, b1.results) # When this fires, the mail has been sent, but the SMTP connection is # still up (because smtp.sendmail relies upon the server to hang up). # Spin for a moment to avoid the "unclean reactor" warning that Trial # gives us if we finish before the socket is disconnected. Really, # sendmail() ought to hang up the connection once it is finished: # otherwise a malicious SMTP server could make us consume lots of # memory. d.addCallback(self.stall, 0.1) return d
def add_status_mail(self, fromaddr=None, extraRecipients=None, sendToInterestedUsers=False, **kwargs): """Add an email status target. """ kwargs['fromaddr'] = fromaddr kwargs['extraRecipients'] = extraRecipients kwargs['sendToInterestedUsers'] = sendToInterestedUsers from buildbot.status import mail self.c['status'].append(mail.MailNotifier(**kwargs))
def MailStatus(cfg, project, **kwargs): mail_conf = cfg.get('mail') notifier = mail.MailNotifier(fromaddr=mail_conf['from'], extraRecipients=mail_conf['to'], mode=['failing', 'change'], **kwargs) oldFormatter = notifier.messageFormatter def subject_injector(mode, name, build, results, master_status): obj = oldFormatter(mode, name, build, results, master_status) if results == FAILURE: subject = '{0} build broke: {1}'.format(project, name) else: subject = '{0} build restored: {1}'.format(project, name) obj['subject'] = subject return obj notifier.messageFormatter = subject_injector return notifier
def AddMailNotifier(BuildmasterConfig): try: with open(os.path.join(BUILD_DIR, 'site_config', '.mail_password')) as f: p = f.read() BuildmasterConfig['status'] = [] BuildmasterConfig['status'].extend([ mail.MailNotifier( fromaddr='*****@*****.**', mode='failing', messageFormatter=emailMessage, extraRecipients=[ '*****@*****.**', '*****@*****.**' ], smtpServer='smtp.gmail.com', smtpUser='******', smtpPassword=p, smtpPort=587, ), ]) except Exception as ex: twlog.msg( 'Warning: Not adding MailNotifier. Could not read password file.')
def AutoSetupMaster(c, active_master, mail_notifier=False, mail_notifier_mode=None, public_html=None, templates=None, order_console_by_time=False, tagComparator=None, customEndpoints=None, enable_http_status_push=False, console_repo_filter=None, console_builder_filter=None, web_template_globals=None): """Add common settings and status services to a master. If you wonder what all these mean, PLEASE go check the official doc! http://buildbot.net/buildbot/docs/0.7.12/ or http://buildbot.net/buildbot/docs/latest/full.html - Default number of logs to keep - WebStatus and MailNotifier - Debug ssh port. Just add a file named .manhole beside master.cfg and simply include one line containing 'port = 10101', then you can 'ssh localhost -p' and you can access your buildbot from the inside.""" if active_master.in_production and not active_master.is_production_host: log.err('ERROR: Trying to start the master on the wrong host.') log.err('ERROR: This machine is %s, expected %s.' % (active_master.current_host, active_master.master_host)) raise WrongHostException c['slavePortnum'] = active_master.slave_port c['projectName'] = active_master.project_name c['projectURL'] = config.Master.project_url c['properties'] = {'mastername': GetMastername()} if 'buildbotURL' in c: c['properties']['buildbotURL'] = c['buildbotURL'] # '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.setdefault('status', []) if mail_notifier: # pylint: disable=E1101 c['status'].append( mail.MailNotifier(fromaddr=active_master.from_address, mode=mail_notifier_mode or 'problem', relayhost=config.Master.smtp, lookup=FilterDomain())) # Add in the pubsub pusher, which pushes all status updates to a pubsub # topic. This will not run unless is_production_host is set to True. # This will fail on a production host if it cannot find the service # account file. pubsub_pusher = pubsub_json_status_push.StatusPush.CreateStatusPush( activeMaster=active_master) if pubsub_pusher: c['status'].append(pubsub_pusher) else: log.msg('Pubsub not enabled.') # For all production masters, notify our health-monitoring webapp. if enable_http_status_push: blacklist = ( 'buildETAUpdate', #'buildFinished', 'buildStarted', 'buildedRemoved', 'builderAdded', 'builderChangedState', 'buildsetSubmitted', 'changeAdded', 'logFinished', 'logStarted', 'requestCancelled', 'requestSubmitted', 'slaveConnected', 'slaveDisconnected', 'stepETAUpdate', 'stepFinished', 'stepStarted', 'stepText2Changed', 'stepTextChanged', ) c['status'].append( HttpStatusPush( 'https://chromium-build-logs.appspot.com/status_receiver', blackList=blacklist)) # Enable Chrome Build Extract status push if configured. This requires the # configuration file to be defined and valid for this master. status_push = None try: status_push = cbe_json_status_push.StatusPush.load( active_master, pushInterval=30, # Push every 30 seconds. ) except cbe_json_status_push.ConfigError as e: log.err( None, 'Failed to load configuration; not installing CBE status ' 'push: %s' % (e.message, )) if status_push: # A status push configuration was identified. c['status'].append(status_push) kwargs = {} if public_html: kwargs['public_html'] = public_html kwargs['order_console_by_time'] = order_console_by_time # In Buildbot 0.8.4p1, pass provide_feeds as a list to signal what extra # services Buildbot should be able to provide over HTTP. if buildbot.version == '0.8.4p1': kwargs['provide_feeds'] = ['json'] if active_master.master_port: # Actions we want to allow must be explicitly listed here. # Deliberately omitted are: # - gracefulShutdown # - cleanShutdown authz = Authz(forceBuild=True, forceAllBuilds=True, pingBuilder=True, stopBuild=True, stopAllBuilds=True, cancelPendingBuild=True) c['status'].append( CreateWebStatus(active_master.master_port, tagComparator=tagComparator, customEndpoints=customEndpoints, authz=authz, num_events_max=3000, templates=templates, console_repo_filter=console_repo_filter, console_builder_filter=console_builder_filter, web_template_globals=web_template_globals, **kwargs)) if active_master.master_port_alt: c['status'].append( CreateWebStatus(active_master.master_port_alt, tagComparator=tagComparator, customEndpoints=customEndpoints, num_events_max=3000, templates=templates, console_repo_filter=console_repo_filter, console_builder_filter=console_builder_filter, web_template_globals=web_template_globals, **kwargs)) # Add a status logger and a ts_mon flushing receiver. c['status'].append(status_logger.StatusEventLogger()) c['status'].append(monitoring_status_receiver.MonitoringStatusReceiver()) # Keep last build logs, the default is too low. c['buildHorizon'] = 1000 c['logHorizon'] = 500 # Must be at least 2x the number of slaves. c['eventHorizon'] = 200 # Tune cache sizes to speed up web UI. c['caches'] = { 'BuildRequests': 1000, 'Changes': 1000, 'SourceStamps': 1000, 'chdicts': 1000, 'ssdicts': 1000, } # Must be at least 2x the number of on-going builds. c['buildCacheSize'] = 200 # See http://buildbot.net/buildbot/docs/0.8.1/Debug-Options.html for more # details. if os.path.isfile('.manhole'): try: from buildbot import manhole except ImportError: log.msg( 'Using manhole has an implicit dependency on Crypto.Cipher. You ' 'need to install it manually:\n' ' sudo apt-get install python-crypto\n' 'on ubuntu or run:\n' ' pip install --user pycrypto\n' ' pip install --user pyasn1\n') raise # If 'port' is defined, it uses the same valid keys as the current user. values = {} execfile('.manhole', values) if 'debugPassword' in values: c['debugPassword'] = values['debugPassword'] interface = 'tcp:%s:interface=127.0.0.1' % values.get('port', 0) if 'port' in values and 'user' in values and 'password' in values: c['manhole'] = manhole.PasswordManhole(interface, values['user'], values['password']) elif 'port' in values: c['manhole'] = manhole.AuthorizedKeysManhole( interface, os.path.expanduser("~/.ssh/authorized_keys")) if active_master.buildbucket_bucket and active_master.service_account_path: SetupBuildbucket(c, active_master) SetMasterProcessName()
# change any of these to True to enable; see the manual for more options gracefulShutdown = False, forceBuild = True, # use this to test your slave once it is set up forceAllBuilds = False, pingBuilder = False, stopBuild = False, stopAllBuilds = False, cancelPendingBuild = False, ) status.append(html.WebStatus( http_port = 8080, authz = authz_cfg, change_hook_dialects = { 'github' : True } )) def get_smtp_password(): path = os.path.join(os.path.dirname(__file__), "passwords/smtp") pw = open(path).read().strip() return pw status.append(mail.MailNotifier( fromaddr = "*****@*****.**", sendToInterestedUsers = False, extraRecipients = [ "*****@*****.**" ], useTls = True, relayhost = "smtp.gmail.com", smtpPort = 587, smtpUser = "******", smtpPassword = get_smtp_password(), mode = "failing", builders = ["JaCoCo_ITs_Linux", "JaCoCo_Deploy", "System_Update"] ))
def AutoSetupMaster(c, active_master, mail_notifier=False, mail_notifier_mode=None, public_html=None, templates=None, order_console_by_time=False, tagComparator=None, enable_http_status_push=False): """Add common settings and status services to a master. If you wonder what all these mean, PLEASE go check the official doc! http://buildbot.net/buildbot/docs/0.7.12/ or http://buildbot.net/buildbot/docs/latest/full.html - Default number of logs to keep - WebStatus and MailNotifier - Debug ssh port. Just add a file named .manhole beside master.cfg and simply include one line containing 'port = 10101', then you can 'ssh localhost -p' and you can access your buildbot from the inside.""" c['slavePortnum'] = active_master.slave_port c['projectName'] = active_master.project_name c['projectURL'] = config.Master.project_url c['properties'] = {'mastername': GetMastername()} if 'buildbotURL' in c: c['properties']['buildbotURL'] = c['buildbotURL'] # '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.setdefault('status', []) if mail_notifier: # pylint: disable=E1101 c['status'].append( mail.MailNotifier(fromaddr=active_master.from_address, mode=mail_notifier_mode or 'problem', relayhost=config.Master.smtp, lookup=FilterDomain())) # For all production masters, notify our health-monitoring webapp. if enable_http_status_push: blacklist = ( 'buildETAUpdate', #'buildFinished', 'buildStarted', 'buildedRemoved', 'builderAdded', 'builderChangedState', 'buildsetSubmitted', 'changeAdded', 'logFinished', 'logStarted', 'requestCancelled', 'requestSubmitted', 'slaveConnected', 'slaveDisconnected', 'stepETAUpdate', 'stepFinished', 'stepStarted', 'stepText2Changed', 'stepTextChanged', ) c['status'].append( HttpStatusPush( 'https://chromium-build-logs.appspot.com/status_receiver', blackList=blacklist)) kwargs = {} if public_html: kwargs['public_html'] = public_html kwargs['order_console_by_time'] = order_console_by_time # In Buildbot 0.8.4p1, pass provide_feeds as a list to signal what extra # services Buildbot should be able to provide over HTTP. if buildbot.version == '0.8.4p1': kwargs['provide_feeds'] = ['json'] if active_master.master_port: # Actions we want to allow must be explicitly listed here. # Deliberately omitted are: # - gracefulShutdown # - cleanShutdown authz = Authz(forceBuild=True, forceAllBuilds=True, pingBuilder=True, stopBuild=True, stopAllBuilds=True, cancelPendingBuild=True) c['status'].append( CreateWebStatus(active_master.master_port, tagComparator=tagComparator, authz=authz, num_events_max=3000, templates=templates, **kwargs)) if active_master.master_port_alt: c['status'].append( CreateWebStatus(active_master.master_port_alt, tagComparator=tagComparator, num_events_max=3000, templates=templates, **kwargs)) # Keep last build logs, the default is too low. c['buildHorizon'] = 1000 c['logHorizon'] = 500 # Must be at least 2x the number of slaves. c['eventHorizon'] = 200 # Tune cache sizes to speed up web UI. c['caches'] = { 'BuildRequests': 1000, 'Changes': 1000, 'SourceStamps': 1000, 'chdicts': 1000, 'ssdicts': 1000, } # Must be at least 2x the number of on-going builds. c['buildCacheSize'] = 200 # See http://buildbot.net/buildbot/docs/0.8.1/Debug-Options.html for more # details. if os.path.isfile('.manhole'): try: from buildbot import manhole except ImportError: log.msg( 'Using manhole has an implicit dependency on Crypto.Cipher. You ' 'need to install it manually:\n' ' sudo apt-get install python-crypto\n' 'on ubuntu or run:\n' ' pip install --user pycrypto\n' ' pip install --user pyasn1\n') raise # If 'port' is defined, it uses the same valid keys as the current user. values = {} execfile('.manhole', values) if 'debugPassword' in values: c['debugPassword'] = values['debugPassword'] interface = 'tcp:%s:interface=127.0.0.1' % values.get('port', 0) if 'port' in values and 'user' in values and 'password' in values: c['manhole'] = manhole.PasswordManhole(interface, values['user'], values['password']) elif 'port' in values: c['manhole'] = manhole.AuthorizedKeysManhole( interface, os.path.expanduser("~/.ssh/authorized_keys"))
# # Initial Contributors: # Nokia Corporation - initial contribution. # # Contributors: # # Description: # # from buildbot.status import html, mail, words web = html.WebStatus(http_port=8010) allBuildsEmail = mail.MailNotifier( fromaddr="*****@*****.**", extraRecipients=["*****@*****.**"], sendToInterestedUsers=False) breakageEmail = mail.MailNotifier(fromaddr="*****@*****.**", lookup=mail.Domain("webkit.org"), mode="failing") IRC = words.IRC( host="irc.freenode.net", nick="webkit-build", channels=["#webkit-build"], # announceAllBuilds=True ) def getStatusListeners(): return [web, allBuildsEmail, breakageEmail, IRC]
def Config(self): return { 'projectName': "Clementine", 'projectURL': "http://www.clementine-player.org/", 'buildbotURL': "http://buildbot.clementine-player.org/", 'slavePortnum': 9989, 'slaves': self.slaves, 'builders': self.builders, 'change_source': [ builders.GitPoller("Android-Remote"), builders.GitPoller("Clementine"), builders.GitPoller("Dependencies"), builders.GitPoller("Website"), ], 'status': [ html.WebStatus( http_port="tcp:8010", authz=authz.Authz( forceBuild=True, forceAllBuilds=True, stopBuild=True, stopAllBuilds=True, cancelPendingBuild=True, cancelAllPendingBuilds=True, stopChange=True, ), ), mail.MailNotifier( fromaddr="*****@*****.**", lookup="gmail.com", mode="failing", ), ], 'schedulers': [ basic.SingleBranchScheduler( name="automatic", change_filter=filter.ChangeFilter(project="clementine", branch="master"), treeStableTimer=2 * 60, builderNames=self.auto_builder_names, ), basic.SingleBranchScheduler( name="dependencies", change_filter=filter.ChangeFilter(project="dependencies", branch="master"), treeStableTimer=2 * 60, builderNames=[ 'Mac Dependencies', 'Windows Dependencies', ], ), basic.SingleBranchScheduler( name="website", change_filter=filter.ChangeFilter(project="website", branch="master"), treeStableTimer=2 * 60, builderNames=[ "Transifex website POT push", ], ), basic.SingleBranchScheduler( name="android-remote", change_filter=filter.ChangeFilter(project="android-remote", branch="master"), treeStableTimer=2 * 60, builderNames=[ "Android Remote", ], ), forcesched.ForceScheduler( name="force", reason=forcesched.FixedParameter(name="reason", default="force build"), branch=forcesched.StringParameter(name="branch", default="master"), revision=forcesched.FixedParameter(name="revision", default=""), repository=forcesched.FixedParameter(name="repository", default=""), project=forcesched.FixedParameter(name="project", default=""), properties=[], builderNames=[x['name'] for x in self.builders], ), timed.Nightly( name="transifex_pull", change_filter=filter.ChangeFilter(project="clementine", branch="master"), hour=10, minute=0, dayOfWeek=0, branch="master", builderNames=[ "Transifex PO pull", "Transifex website PO pull", "Transifex Android PO pull", ], ), ], }