Bug 1258568 - Email r-d when a release starts r=Callek draft
authorRail Aliiev <rail@mozilla.com>
Mon, 21 Mar 2016 19:28:03 -0400
changeset 6695 2f410a8e744d3353193ff02e091592701cab87de
parent 6694 2b4707b2f293891072589f5c2d54f239d05eba94
push id42
push userbmo:rail@mozilla.com
push dateMon, 21 Mar 2016 23:28:26 +0000
reviewersCallek
bugs1258568
Bug 1258568 - Email r-d when a release starts r=Callek MozReview-Commit-ID: BC2cHMlt0MD
buildfarm/release/release-runner.py
--- a/buildfarm/release/release-runner.py
+++ b/buildfarm/release/release-runner.py
@@ -23,16 +23,17 @@ from release.info import readBranchConfi
 from release.l10n import parsePlainL10nChangesets
 from release.versions import getAppVersion
 from releasetasks import make_task_graph
 from taskcluster import Scheduler, Index, Queue
 from taskcluster.utils import slugId
 from util.hg import mercurial
 from util.retry import retry
 from util.file import load_config, get_config
+from util.sendmail import sendmail
 
 log = logging.getLogger(__name__)
 
 
 # both CHECKSUMS and ALL_FILES have been defined to improve the release sanity
 # en-US binaries timing by whitelisting artifacts of interest - bug 1251761
 CHECKSUMS = set([
     '.checksums',
@@ -137,17 +138,16 @@ class ReleaseRunner(object):
         except requests.HTTPError, e:
             log.warning('Caught HTTPError: %s' % e.response.content)
             log.warning('status update failed, continuing...', exc_info=True)
 
     def mark_as_completed(self, release):#, enUSPlatforms):
         log.info('mark as completed %s' % release['name'])
         self.release_api.update(release['name'], complete=True,
                                 status='Started')
-                                #enUSPlatforms=json.dumps(enUSPlatforms))
 
     def mark_as_failed(self, release, why):
         log.info('mark as failed %s' % release['name'])
         self.release_api.update(release['name'], ready=False, status=why)
 
 
 def getPartials(release):
     partials = {}
@@ -155,63 +155,49 @@ def getPartials(release):
         partialVersion, buildNumber = p.split('build')
         partials[partialVersion] = {
             'appVersion': getAppVersion(partialVersion),
             'buildNumber': buildNumber,
         }
     return partials
 
 
-# TODO: actually do this. figure out how to get the right info without having a release config.
-# maybe we don't need revision info any more? or maybe we have from some other source like branch config?
-#def sendMailRD(smtpServer, From, cfgFile, r):
-#    # Send an email to the mailing after the build
-#    contentMail = ""
-#    release_config = readReleaseConfig(cfgFile)
-#    sources = release_config['sourceRepositories']
-#    To = release_config['ImportantRecipients']
-#    comment = r.get("comment")
-#
-#    if comment:
-#        contentMail += "Comment:\n" + comment + "\n\n"
-#
-#    contentMail += "A new build has been submitted through ship-it:\n"
-#
-#    for name, source in sources.items():
-#
-#        if name == "comm":
-#            # Thunderbird
-#            revision = source["revision"]
-#            path = source["path"]
-#        else:
-#            revision = source["revision"]
-#            path = source["path"]
-#
-#        # For now, firefox has only one source repo but Thunderbird has two
-#        contentMail += name + " commit: https://hg.mozilla.org/" + path + "/rev/" + revision + "\n"
-#
-#    contentMail += "\nCreated by " + r["submitter"] + "\n"
-#
-#    contentMail += "\nStarted by " + r["starter"] + "\n"
-#
-#    subjectPrefix = ""
-#
-#    # On r-d, we prefix the subject of the email in order to simplify filtering
-#    # We don't do it for thunderbird
-#    if "Fennec" in r["name"]:
-#        subjectPrefix = "[mobile] "
-#    if "Firefox" in r["name"]:
-#        subjectPrefix = "[desktop] "
-#
-#    Subject = subjectPrefix + 'Build of %s' % r["name"]
-#
-#    sendmail(from_=From, to=To, subject=Subject, body=contentMail,
-#             smtp_server=smtpServer)
+def email_release_drivers(smtp_server, from_, to, release, graph_id):
+    # Send an email to the mailing after the build
+
+    content = """\
+A new build has been submitted through ship-it:
+
+Commit: https://hg.mozilla.org/{path}/rev/{revision}
+Task graph: https://tools.taskcluster.net/task-graph-inspector/#{task_graph_id}/
+
+Created by {submitter}
+Started by {starter}
+
+
+""".format(path=release["branch"], revision=release["mozillaRevision"],
+           submitter=release["submitter"], starter=release["starter"],
+           task_graph_id=graph_id)
 
-# TODO: deal with platform-specific locales
+    comment = release.get("comment")
+    if comment:
+        content += "Comment:\n" + comment + "\n\n"
+
+    # On r-d, we prefix the subject of the email in order to simplify filtering
+    if "Fennec" in release["name"]:
+        subject_prefix = "[mobile] "
+    if "Firefox" in release["name"]:
+        subject_prefix = "[desktop] "
+
+    subject = subject_prefix + 'Build of %s' % release["name"]
+
+    sendmail(from_=from_, to=to, subject=subject, body=content,
+             smtp_server=smtp_server)
+
+
 def get_platform_locales(l10n_changesets, platform):
     # hardcode ja/ja-JP-mac exceptions
     if platform == "macosx64":
         ignore = "ja"
     else:
         ignore = "ja-JP-mac"
 
     return [l for l in l10n_changesets.keys() if l != ignore]
@@ -541,16 +527,19 @@ def main(options):
             rr.update_status(release, "Submitting task graph")
 
             log.info("Task graph generated!")
             import pprint
             log.debug(pprint.pformat(graph, indent=4, width=160))
             print scheduler.createTaskGraph(graph_id, graph)
 
             rr.mark_as_completed(release)
+            email_release_drivers(smtp_server=smtp_server, from_=notify_from,
+                                  to=notify_to, release=release,
+                                  graph_id=graph_id)
         except:
             # We explicitly do not raise an error here because there's no
             # reason not to start other releases if creating the Task Graph
             # fails for another one. We _do_ need to set this in order to exit
             # with the right code, though.
             rc = 2
             rr.update_status(release, 'Failed to start release promotion')
             log.exception("Failed to start release promotion for {}: ".format(release))