Bug 1213011 - Allow post-build tasks to use build_{name,type,product} variables. r=garndt

This commit is contained in:
Alexandre Poirot
2015-10-28 09:56:17 -07:00
parent 7a74ec1e10
commit 8907b885a6
3 changed files with 15 additions and 10 deletions

View File

@@ -110,7 +110,7 @@ def decorate_task_treeherder_routes(task, suffix):
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.
@@ -118,15 +118,9 @@ def decorate_task_json_routes(build, task, json_routes, parameters):
: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
@@ -436,6 +430,14 @@ class Graph(object):
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
@@ -445,8 +447,7 @@ class Graph(object):
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)

View File

@@ -57,6 +57,8 @@ task:
extra:
build_product: '{{build_product}}'
build_name: '{{build_name}}'
build_type: '{{build_type}}'
index:
rank: {{pushlog_id}}
treeherder:

View File

@@ -57,6 +57,8 @@ task:
extra:
build_product: 'b2g'
build_name: '{{build_name}}'
build_type: '{{build_type}}'
index:
rank: {{pushlog_id}}
treeherder: