[151660] contrib/buildbot-test/master.cfg

mojca at macports.org mojca at macports.org
Fri Aug 19 06:29:28 PDT 2016


Revision: 151660
          https://trac.macports.org/changeset/151660
Author:   mojca at macports.org
Date:     2016-08-19 06:29:28 -0700 (Fri, 19 Aug 2016)
Log Message:
-----------
buildbot-test: preliminary support for email notifications

Modified Paths:
--------------
    contrib/buildbot-test/master.cfg

Modified: contrib/buildbot-test/master.cfg
===================================================================
--- contrib/buildbot-test/master.cfg	2016-08-19 13:11:11 UTC (rev 151659)
+++ contrib/buildbot-test/master.cfg	2016-08-19 13:29:28 UTC (rev 151660)
@@ -4,6 +4,7 @@
 
 import json
 import os
+import re
 
 def _path(name):
     return os.path.join(os.path.dirname(__file__), name)
@@ -498,6 +499,64 @@
     cancelPendingBuild = 'auth',
 )
 
+from buildbot.plugins import util
+
+def portWatcherMessageFormatter(mode, name, build, results, master_status):
+    result = util.Results[results]
+    text = list()
+    text.append("Status:       {:s}".format(result.title()))
+    text.append("Build slave:  {:s}".format(build.getSlavename()))
+    if master_status.getURLForThing(build):
+        text.append("Full logs:    {:s}".format(master_status.getURLForThing(build)))
+        text.append("Build reason: {:s}".format(build.getReason()))
+        text.append("Port list:    {:s}".format(build.getProperty('fullportlist')))
+        text.append("Subport list:\n\t- {:s}".format(build.getProperty('subportlist').replace(" ", "\n\t- ")))
+        text.append("Variants:     {:s}".format(build.getProperty('variants')))
+        text.append("Revision:     {:s}".format(build.getProperty('revision')))
+        #text.append("Time:         {}".format(build.getTimes()[1] - build.getTimes()[0]))
+        text.append(u"Blamelist:   {:s}".format(",".join(build.getResponsibleUsers())))
+
+        text.append("\nLog from failed builds:")
+        summary_step = [x for x in build.getSteps() if x.getName() == "summary"][0]
+        summary_log  = [x for x in summary_step.getLogs() if x.getName() == "stdio"][0]
+        failed_ports_dict = {}
+        pattern = re.compile("^Building '(?P<port>.*?)'.*?(\(failed to install dependency '(?P<dependency>.*?)'\))?$")
+        # iterate through all the ports being built
+        for line in summary_log.getText().splitlines():
+            # in case of a build error, print the error and add the broken port(s) to the list
+            if 'ERROR' in line:
+                text.append("\t" + line)
+                match = pattern.match(line)
+                if match:
+                    for key in ['port', 'dependency']:
+                        if key in match.groupdict():
+                            port = match.groupdict()[key]
+                            if port:
+                                failed_ports_dict[port] = True
+        failed_ports = sorted(failed_ports_dict.keys())
+        text.append("\nBroken ports:\n\t- {:s}".format("\n\t- ".join(failed_ports)))
+
+        maintainers_to_notify = list()
+        # TODO
+        text.append("\nResponsible maintainers:\n\t(is there a way to create the list without installing MacPorts to the server?)")
+
+        # links to individual builds
+        text.append("\nLinks to individual build jobs:")
+        trigger_step = [x for x in build.getSteps() if x.getName() == "trigger"][0]
+        build_urls_dict = trigger_step.getURLs()
+        # TODO; sorting won't work properly for
+        # - ports-10.11-x86_64-builder #99
+        # - ports-10.11-x86_64-builder #100
+        build_urls_keys = sorted(build_urls_dict.keys())
+        for k in build_urls_keys:
+            text.append("- {:s}\n  {:s}".format(k, build_urls_dict[k]))
+        text.append("\nBest regards,\n\tyour BuildBot")
+    return {
+        'body'    : "\n".join(text),
+        'type'    : 'plain',
+        'subject' : "[MacPorts builds] Build {:s}".format(result.title())
+    }
+
 if production:
     # send mail about base failures to users on the blamelist
     from buildbot.status.mail import MailNotifier
@@ -509,6 +568,28 @@
         mode="problem")
     c['status'].append(mn)
 
+    mn = MailNotifier(
+        fromaddr="noreply at macports.org",
+        mode=("failing"),
+        builders=portwatcher_buildernames,
+        #extraRecipients=["..."],
+        sendToInterestedUsers=False, # True
+        messageFormatter=portWatcherMessageFormatter)
+    # c['status'].append(mn)
+
+    # notifications about exceptions
+    mn = MailNotifier(
+        fromaddr="noreply at macports.org",
+        mode=("exception"),
+        extraRecipients=["admin at macosforge.org"],
+        sendToInterestedUsers=False)
+    # c['status'].append(mn)
+
+
+    # TODO: This is the old mail notifier;
+    # - useful functionality could be copied
+    # - then the code should be removed
+    #
     import subprocess
     from twisted.internet import defer
     # notifier that sends mail to last committers and maintainers of failed ports
@@ -553,9 +634,9 @@
                 dl.append(d)
             return defer.gatherResults(dl)
 
-    mn = PortsMailNotifier(fromaddr="noreply at macports.org", lookup="", relayhost="localhost",
-        builders=ports_buildernames, mode="failing")
-    c['status'].append(mn)
+#    mn = PortsMailNotifier(fromaddr="noreply at macports.org", lookup="", relayhost="localhost",
+#        builders=ports_buildernames, mode="failing")
+#    c['status'].append(mn)
 
 ####### PROJECT IDENTITY
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160819/f8a01ed5/attachment-0001.html>


More information about the macports-changes mailing list