diff --git a/taskcluster/gecko_taskgraph/decision.py b/taskcluster/gecko_taskgraph/decision.py index 71a8e1ddaf30..d38483611cc3 100644 --- a/taskcluster/gecko_taskgraph/decision.py +++ b/taskcluster/gecko_taskgraph/decision.py @@ -7,6 +7,7 @@ import os import json import logging import time +import shutil import sys from collections import defaultdict @@ -251,6 +252,15 @@ def taskgraph_decision(options, parameters=None): if len(push_schedules) > 0: write_artifact("bugbug-push-schedules.json", push_schedules.popitem()[1]) + # cache run-task & misc/fetch-content + scripts_root_dir = os.path.join( + "/builds/worker/checkouts/gecko/taskcluster/scripts" + ) + run_task_file_path = os.path.join(scripts_root_dir, "run-task") + fetch_content_file_path = os.path.join(scripts_root_dir, "misc/fetch-content") + shutil.copy2(run_task_file_path, ARTIFACTS_DIR) + shutil.copy2(fetch_content_file_path, ARTIFACTS_DIR) + # actually create the graph create_tasks( tgg.graph_config, diff --git a/taskcluster/gecko_taskgraph/test/test_transforms_job.py b/taskcluster/gecko_taskgraph/test/test_transforms_job.py index 44f2a6a9e179..43d9c18d3667 100644 --- a/taskcluster/gecko_taskgraph/test/test_transforms_job.py +++ b/taskcluster/gecko_taskgraph/test/test_transforms_job.py @@ -60,6 +60,8 @@ def transform(monkeypatch, config): This gives test functions an easy way to generate the inputs required for many of the `run_using` subsystems. """ + # Needed by 'generic_worker_run_task' + monkeypatch.setenv("TASK_ID", "fakeid") def inner(task_input): task = deepcopy(TASK_DEFAULTS) diff --git a/taskcluster/gecko_taskgraph/transforms/job/run_task.py b/taskcluster/gecko_taskgraph/transforms/job/run_task.py index c2391d3d4dcd..759bf2c66f4f 100644 --- a/taskcluster/gecko_taskgraph/transforms/job/run_task.py +++ b/taskcluster/gecko_taskgraph/transforms/job/run_task.py @@ -6,6 +6,8 @@ Support for running jobs that are invoked via the `run-task` script. """ +import os + from mozpack import path from gecko_taskgraph.transforms.task import taskref_or_string @@ -91,9 +93,11 @@ worker_defaults = { def script_url(config, script): - return config.params.file_url( - f"taskcluster/scripts/{script}", - ) + if "TASK_ID" not in os.environ: + raise Exception("TASK_ID must be defined to use run-task on generic-worker") + task_id = os.environ["TASK_ID"] + tc_url = "http://firefox-ci-tc.services.mozilla.com" + return f"{tc_url}/api/queue/v1/task/{task_id}/artifacts/public/{script}" @run_job_using( @@ -198,7 +202,7 @@ def generic_worker_run_task(config, job, taskdesc): worker["mounts"].append( { "content": { - "url": script_url(config, "misc/fetch-content"), + "url": script_url(config, "fetch-content"), }, "file": "./fetch-content", }