Bug 1213011 - Allow post-build tasks to use build_{name,type,product} variables. r=garndt
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 28 Oct 2015 09:56:17 -0700
changeset 305116 778030b1b88b7857d296eff8d63850c701c35139
parent 305115 80a9d5e49dc61ab479f988fbb6dfa3864a4ee0ab
child 305117 d41522b5aed48941893f47d57c54e9cab6e5b5d1
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgarndt
bugs1213011
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1213011 - Allow post-build tasks to use build_{name,type,product} variables. r=garndt
testing/taskcluster/mach_commands.py
testing/taskcluster/tasks/build.yml
testing/taskcluster/tasks/phone_build.yml
--- a/testing/taskcluster/mach_commands.py
+++ b/testing/taskcluster/mach_commands.py
@@ -105,33 +105,27 @@ def decorate_task_treeherder_routes(task
     if 'routes' not in task:
         task['routes'] = []
 
     treeheder_env = task['extra'].get('treeherderEnv', ['staging'])
 
     for env in treeheder_env:
         task['routes'].append('{}.{}'.format(TREEHERDER_ROUTES[env], suffix))
 
-def decorate_task_json_routes(build, task, json_routes, parameters):
+def decorate_task_json_routes(task, json_routes, parameters):
     """
     Decorate the given task with routes.json routes.
 
     :param dict task: task definition.
     :param json_routes: the list of routes to use from routes.json
     :param parameters: dictionary of parameters to use in route templates
     """
-    fmt = parameters.copy()
-    fmt.update({
-        'build_product': task['extra']['build_product'],
-        'build_name': build['build_name'],
-        'build_type': build['build_type'],
-    })
     routes = task.get('routes', [])
     for route in json_routes:
-        routes.append(route.format(**fmt))
+        routes.append(route.format(**parameters))
 
     task['routes'] = routes
 
 def configure_dependent_task(task_path, parameters, taskid, templates, build_treeherder_config):
     """
     Configure a build dependent task. This is shared between post-build and test tasks.
 
     :param task_path: location to the task yaml
@@ -431,27 +425,34 @@ class Graph(object):
 
         all_routes = {}
 
         for build in job_graph:
             interactive = cmdline_interactive or build["interactive"]
             build_parameters = dict(parameters)
             build_parameters['build_slugid'] = slugid()
             build_task = templates.load(build['task'], build_parameters)
+
+            # Copy build_* attributes to expose them to post-build tasks
+            # as well as json routes and tests
+            task_extra = build_task['task']['extra']
+            build_parameters['build_name'] = task_extra['build_name']
+            build_parameters['build_type'] = task_extra['build_type']
+            build_parameters['build_product'] = task_extra['build_product']
+
             set_interactive_task(build_task, interactive)
 
             # try builds don't use cache
             if project == "try":
                 remove_caches_from_task(build_task)
 
             if params['revision_hash']:
                 decorate_task_treeherder_routes(build_task['task'],
                                                 treeherder_route)
-                decorate_task_json_routes(build,
-                                          build_task['task'],
+                decorate_task_json_routes(build_task['task'],
                                           json_routes,
                                           build_parameters)
 
             # Ensure each build graph is valid after construction.
             taskcluster_graph.build_task.validate(build_task)
             graph['tasks'].append(build_task)
 
             test_packages_url, tests_url, mozharness_url = None, None, None
--- a/testing/taskcluster/tasks/build.yml
+++ b/testing/taskcluster/tasks/build.yml
@@ -52,14 +52,16 @@ task:
       GECKO_HEAD_REPOSITORY: '{{head_repository}}'
       GECKO_HEAD_REV: '{{head_rev}}'
       GECKO_HEAD_REF: '{{head_ref}}'
       TOOLTOOL_REPO: 'https://git.mozilla.org/build/tooltool.git'
       TOOLTOOL_REV: 'master'
 
   extra:
     build_product: '{{build_product}}'
+    build_name: '{{build_name}}'
+    build_type: '{{build_type}}'
     index:
       rank: {{pushlog_id}}
     treeherder:
       groupSymbol: tc
       groupName: Submitted by taskcluster
       symbol: B
--- a/testing/taskcluster/tasks/phone_build.yml
+++ b/testing/taskcluster/tasks/phone_build.yml
@@ -52,14 +52,16 @@ task:
       # Common environment variables for checking out gecko
       GECKO_BASE_REPOSITORY: '{{base_repository}}'
       GECKO_HEAD_REPOSITORY: '{{head_repository}}'
       GECKO_HEAD_REV: '{{head_rev}}'
       GECKO_HEAD_REF: '{{head_ref}}'
 
   extra:
     build_product: 'b2g'
+    build_name: '{{build_name}}'
+    build_type: '{{build_type}}'
     index:
       rank: {{pushlog_id}}
     treeherder:
       groupSymbol: tc
       groupName: Submitted by taskcluster
       symbol: B