Bug 1237013 - Add pushdate to taskcluster-build mach target r=wcosta draft
authorGregory Arndt <garndt@mozilla.com>
Tue, 05 Jan 2016 13:34:30 -0600 (2016-01-05)
changeset 319104 6769f94c60e0006e8ef009513409d26d5125888a
parent 319099 aaef0e7e3514acb79418e8fe75f26c6b3d9d18c5
child 512538 597a596d62636352cea01790afa1b9e9242ed623
push id8969
push usergarndt@mozilla.com
push dateTue, 05 Jan 2016 19:34:46 +0000 (2016-01-05)
reviewerswcosta
bugs1237013
milestone46.0a1
Bug 1237013 - Add pushdate to taskcluster-build mach target r=wcosta
testing/taskcluster/mach_commands.py
--- a/testing/taskcluster/mach_commands.py
+++ b/testing/taskcluster/mach_commands.py
@@ -609,29 +609,40 @@ class CIBuild(object):
             head_repository = get_hg_url()
 
         head_rev = params['head_rev']
         if not head_rev:
             head_rev = get_latest_hg_revision(head_repository)
 
         head_ref = params['head_ref'] or head_rev
 
+        # Default to current time if querying the head rev fails
+        pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime())
+        pushinfo = query_pushinfo(params['head_repository'], params['head_rev'])
+        if pushinfo:
+            pushdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(pushinfo.pushdate))
+
         from taskcluster_graph.from_now import (
             json_time_from_now,
             current_json_time,
         )
         build_parameters = dict(gaia_info().items() + {
             'docker_image': docker_image,
             'owner': params['owner'],
             'from_now': json_time_from_now,
             'now': current_json_time(),
             'base_repository': params['base_repository'] or head_repository,
             'head_repository': head_repository,
             'head_rev': head_rev,
             'head_ref': head_ref,
+            'pushdate': pushdate,
+            'pushtime': pushdate[8:],
+            'year': pushdate[0:4],
+            'month': pushdate[4:6],
+            'day': pushdate[6:8],
         }.items())
 
         try:
             build_task = templates.load(params['build_task'], build_parameters)
             set_interactive_task(build_task, params.get('interactive', False))
         except IOError:
             sys.stderr.write(
                 "Could not load build task file.  Ensure path is a relative " \