def create_interactive_action(parameters, graph_config, input, task_group_id, task_id, task): # fetch the original task definition from the taskgraph, to avoid # creating interactive copies of unexpected tasks. Note that this only applies # to docker-worker tasks, so we can assume the docker-worker payload format. decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels( parameters, graph_config) label = task['metadata']['name'] def edit(task): if task.label != label: return task task_def = task.task # drop task routes (don't index this!) task_def['routes'] = [] # only try this once task_def['retries'] = 0 # short expirations, at least 3 hour maxRunTime task_def['deadline'] = {'relative-datestamp': '12 hours'} task_def['created'] = {'relative-datestamp': '0 hours'} task_def['expires'] = {'relative-datestamp': '1 day'} payload = task_def['payload'] payload['maxRunTime'] = max(3600 * 3, payload.get('maxRunTime', 0)) # no caches task_def['scopes'] = [ s for s in task_def['scopes'] if not s.startswith('docker-worker:cache:') ] payload['cache'] = {} # no artifacts payload['artifacts'] = {} # enable interactive mode payload.setdefault('features', {})['interactive'] = True payload.setdefault('env', {})['TASKCLUSTER_INTERACTIVE'] = 'true' return task # Create the task and any of its dependencies. This uses a new taskGroupId to avoid # polluting the existing taskGroup with interactive tasks. label_to_taskid = create_tasks([label], full_task_graph, label_to_taskid, parameters, modifier=edit) taskId = label_to_taskid[label] if input and 'notify' in input: email = input['notify'] # no point sending to a noreply address! if email == '*****@*****.**': return info = { 'url': 'https://tools.taskcluster.net/tasks/{}/connect'.format(taskId), 'label': label, 'revision': parameters['head_rev'], 'repo': parameters['head_repository'], } send_email(email, subject=EMAIL_SUBJECT.format(**info), content=EMAIL_CONTENT.format(**info), link={ 'text': 'Connect', 'href': info['url'], }, use_proxy=True)
def create_interactive_action(parameters, graph_config, input, task_group_id, task_id): # fetch the original task definition from the taskgraph, to avoid # creating interactive copies of unexpected tasks. Note that this only applies # to docker-worker tasks, so we can assume the docker-worker payload format. decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels( parameters, graph_config) task = taskcluster.get_task_definition(task_id) label = task["metadata"]["name"] def edit(task): if task.label != label: return task task_def = task.task # drop task routes (don't index this!) task_def["routes"] = [] # only try this once task_def["retries"] = 0 # short expirations, at least 3 hour maxRunTime task_def["deadline"] = {"relative-datestamp": "12 hours"} task_def["created"] = {"relative-datestamp": "0 hours"} task_def["expires"] = {"relative-datestamp": "1 day"} # filter scopes with the SCOPE_WHITELIST task.task["scopes"] = [ s for s in task.task.get("scopes", []) if any( p.match(s) for p in SCOPE_WHITELIST) ] payload = task_def["payload"] # make sure the task runs for long enough.. payload["maxRunTime"] = max(3600 * 3, payload.get("maxRunTime", 0)) # no caches or artifacts payload["cache"] = {} payload["artifacts"] = {} # enable interactive mode payload.setdefault("features", {})["interactive"] = True payload.setdefault("env", {})["TASKCLUSTER_INTERACTIVE"] = "true" return task # Create the task and any of its dependencies. This uses a new taskGroupId to avoid # polluting the existing taskGroup with interactive tasks. action_task_id = os.environ.get("TASK_ID") label_to_taskid = create_tasks( graph_config, [label], full_task_graph, label_to_taskid, parameters, decision_task_id=action_task_id, modifier=edit, ) taskId = label_to_taskid[label] logger.info( "Created interactive task {}; sending notification".format(taskId)) if input and "notify" in input: email = input["notify"] # no point sending to a noreply address! if email == "*****@*****.**": return info = { "url": taskcluster_urls.ui(get_root_url(False), "tasks/{}/connect".format(taskId)), "label": label, "revision": parameters["head_rev"], "repo": parameters["head_repository"], } send_email( email, subject=EMAIL_SUBJECT.format(**info), content=EMAIL_CONTENT.format(**info), link={ "text": "Connect", "href": info["url"], }, use_proxy=True, )