Use tagged version in bugbug hooks (#640)

Fixes #634
This commit is contained in:
Boris Feld 2019-06-27 15:47:57 +02:00 коммит произвёл Marco
Родитель 89bba8efca
Коммит 2b48e153cb
2 изменённых файлов: 17 добавлений и 15 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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(