From bb9111720471ba9d5e1e781ac24a48c2e5aa9886 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Roukala=20=28n=C3=A9=20Peres=29?= Date: Sat, 1 Oct 2022 06:46:19 +0300 Subject: [PATCH] ci/b2c: add support for the new format of CI_RUNNER_TAGS MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Seems like Gitlab did not follow their own documentation: ``` CI_RUNNER_TAGS 8.10 0.5 A comma-separated list of the runner tags. ``` But it would seem like a gitlab update brought json-style lists which broke: ``` CI_RUNNER_TAGS = '["keywords-gateway", "CI-gateway"]' ``` This commit adds support for both style. Signed-off-by: Martin Roukala (né Peres) Reviewed-by: John Brooks Part-of: --- .gitlab-ci/b2c/b2c.yml.jinja2.jinja2 | 3 +-- .gitlab-ci/b2c/generate_b2c.py | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci/b2c/b2c.yml.jinja2.jinja2 b/.gitlab-ci/b2c/b2c.yml.jinja2.jinja2 index 2ac849a..ae5059b 100644 --- a/.gitlab-ci/b2c/b2c.yml.jinja2.jinja2 +++ b/.gitlab-ci/b2c/b2c.yml.jinja2.jinja2 @@ -3,9 +3,8 @@ version: 1 # Rules to match for a machine to qualify target: {% if tags %} -{% set b2ctags = tags.split(',') %} tags: -{% for tag in b2ctags %} +{% for tag in tags %} - '{{ tag | trim }}' {% endfor %} {% endif %} diff --git a/.gitlab-ci/b2c/generate_b2c.py b/.gitlab-ci/b2c/generate_b2c.py index a68b34a..976c5b4 100755 --- a/.gitlab-ci/b2c/generate_b2c.py +++ b/.gitlab-ci/b2c/generate_b2c.py @@ -24,6 +24,7 @@ from jinja2 import Environment, FileSystemLoader from argparse import ArgumentParser from os import environ, path +import json parser = ArgumentParser() @@ -69,7 +70,10 @@ values['log_level'] = args.log_level values['poweroff_delay'] = args.poweroff_delay values['session_end_regex'] = args.session_end_regex values['session_reboot_regex'] = args.session_reboot_regex -values['tags'] = args.tags +try: + values['tags'] = json.loads(args.tags) +except json.decoder.JSONDecodeError: + values['tags'] = args.tags.split(",") values['template'] = args.template values['timeout_boot_minutes'] = args.timeout_boot_minutes values['timeout_boot_retries'] = args.timeout_boot_retries -- 2.7.4