Bug 1258568 - Email r-d when a release starts r=Callek
authorRail Aliiev <rail@mozilla.com>
Mon, 21 Mar 2016 19:28:03 -0400
changeset 6632 6d7c4e8f0343b1b8ca5f6c4ad266be019b50f24f
parent 6631 0121cecfae81a2da3bc6ad124f90267a40f12489
child 6633 6f7160aff6ac87a2aca5f4039396bfad843e5932
push id4955
push userraliiev@mozilla.com
push dateTue, 22 Mar 2016 17:32:03 +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',
@@ -159,17 +160,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 = {}
@@ -177,63 +177,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]
@@ -563,16 +549,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))