bug 1442793 - get_artifact_prefix and get_artifact_path. r?bhearsum
MozReview-Commit-ID: E1VBN88h03M
--- a/taskcluster/taskgraph/util/taskcluster.py
+++ b/taskcluster/taskgraph/util/taskcluster.py
@@ -9,16 +9,17 @@ from __future__ import absolute_import,
import datetime
import functools
import yaml
import requests
import logging
from mozbuild.util import memoize
from requests.packages.urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
+from taskgraph.task import Task
_TC_ARTIFACT_LOCATION = \
'https://queue.taskcluster.net/v1/task/{task_id}/artifacts/public/build/{postfix}'
logger = logging.getLogger(__name__)
# this is set to true for `mach taskgraph action-callback --test`
testing = False
@@ -85,16 +86,29 @@ def get_artifact(task_id, path, use_prox
return _handle_artifact(path, response)
def list_artifacts(task_id, use_proxy=False):
response = _do_request(get_artifact_url(task_id, '', use_proxy).rstrip('/'))
return response.json()['artifacts']
+def get_artifact_prefix(task):
+ prefix = None
+ if isinstance(task, dict):
+ prefix = task.get('attributes', {}).get("artifact_prefix")
+ elif isinstance(task, Task):
+ prefix = task.attributes.get("artifact_prefix")
+ return prefix or "public/build"
+
+
+def get_artifact_path(task, path):
+ return "{}/{}".format(get_artifact_prefix(task), path)
+
+
def get_index_url(index_path, use_proxy=False, multiple=False):
if use_proxy:
INDEX_URL = 'http://taskcluster/index/v1/task{}/{}'
else:
INDEX_URL = 'https://index.taskcluster.net/v1/task{}/{}'
return INDEX_URL.format('s' if multiple else '', index_path)