diff --git a/.taskcluster.yml b/.taskcluster.yml index 824e7645..17531ce5 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -268,7 +268,7 @@ tasks: - "git clone --quiet ${repository} && cd bugbug && git -c advice.detachedHead=false checkout ${head_rev} && - python infra/set_hook_env_var.py TAG $VERSION infra/taskcluster-hook-annotate.json && + python infra/set_hook_version.py $VERSION infra/taskcluster-hook-annotate.json && taskboot --target . build-hook infra/taskcluster-hook-annotate.json project-relman bugbug-annotate" metadata: name: bugbug update annotate hook @@ -303,7 +303,7 @@ tasks: - "git clone --quiet ${repository} && cd bugbug && git -c advice.detachedHead=false checkout ${head_rev} && - python infra/set_hook_env_var.py TAG $VERSION infra/taskcluster-hook-pipeline-start.json && + python infra/set_hook_version.py $VERSION infra/taskcluster-hook-pipeline-start.json && taskboot --target . build-hook infra/taskcluster-hook-pipeline-start.json project-relman bugbug" routes: - project.relman.bugbug.deploy_ending @@ -339,7 +339,7 @@ tasks: - "git clone --quiet ${repository} && cd bugbug && git -c advice.detachedHead=false checkout ${head_rev} && - python infra/set_hook_env_var.py TAG $VERSION infra/taskcluster-hook-check-models-start.json && + python infra/set_hook_version.py $VERSION infra/taskcluster-hook-check-models-start.json && taskboot --target . build-hook infra/taskcluster-hook-check-models-start.json project-relman bugbug-checks" metadata: name: bugbug update check hook diff --git a/infra/set_hook_env_var.py b/infra/set_hook_version.py similarity index 62% rename from infra/set_hook_env_var.py rename to infra/set_hook_version.py index 18fbe53c..f8014ed5 100644 --- a/infra/set_hook_env_var.py +++ b/infra/set_hook_version.py @@ -11,16 +11,10 @@ import sys def main(raw_args): parser = argparse.ArgumentParser() parser.add_argument( - "env_name", - metavar="env-name", + "version", + metavar="version", type=str, - help="The name of the environment variable to set", - ) - parser.add_argument( - "env_value", - metavar="env-value", - type=str, - help="The value of the environment variable to set", + help="The version to set in the hook definition", ) parser.add_argument( "hook_file", @@ -34,9 +28,17 @@ def main(raw_args): with open(args.hook_file, "r") as hook_file: hook_data = json.load(hook_file) - # Insert or replace the environment variable - hook_env = hook_data["task"]["payload"]["env"] - hook_env[args.env_name] = args.env_value + task_payload = hook_data["task"]["payload"] + + task_image = task_payload.get("image") + + # 1) Insert or replace the environment variable + hook_env = task_payload["env"] + hook_env["TAG"] = args.version + + # 2) Set the version for the hook docker image + if task_image and task_image.split(":", 1)[0] == "mozilla/bugbug-spawn-pipeline": + task_payload["image"] = f"mozilla/bugbug-spawn-pipeline:{args.version}" with open(args.hook_file, "w") as hook_file: json.dump(