From 3e2d68fea8e42c94eddb165aabe9c6a1e007b8ba Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Tue, 8 Oct 2024 17:49:24 +0100 Subject: [PATCH] [custom_junit] Make the test prefix configurable via ini file and env var --- callback_plugins/custom_junit.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/callback_plugins/custom_junit.py b/callback_plugins/custom_junit.py index 70bf5ebb..08a88b65 100644 --- a/callback_plugins/custom_junit.py +++ b/callback_plugins/custom_junit.py @@ -6,6 +6,23 @@ import re from ansible.utils._junit_xml import TestCase, TestError, TestFailure, TestSuite, TestSuites +DOCUMENTATION = ''' + callback: custom_junit + type: notification + short_description: TODO + description: + TODO + options: + test_case_prefix: + description: todo + ini: + - section: custom_junit + key: test_case_prefix + env: + - name: JUNIT_TEST_CASE_PREFIX + default: "TEST" + type: string +''' class CallbackModule(JunitCallbackModule): """ @@ -15,11 +32,14 @@ class CallbackModule(JunitCallbackModule): def __init__(self): super(CallbackModule, self).__init__() + self.get_options() # Custom environment variable handling # Update this to parse these values from the config file, as well as the env. self._output_dir = os.path.expanduser("~/.ansible.log") - self._test_case_prefix = os.getenv('JUNIT_TEST_CASE_PREFIX', 'TEST') + # self._test_case_prefix = os.getenv('JUNIT_TEST_CASE_PREFIX', '[TEST]') + # self._test_case_prefix = os.getenv('JUNIT_TEST_CASE_PREFIX', 'TEST') + self._test_case_prefix = self.get_options("test_case_prefix") self._fail_on_ignore = 'true' # this is needed because we use "ignore_errors" on the playbooks so that all the tests are run self._include_setup_tasks_in_report = os.getenv('JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT', 'False').lower() self._hide_task_arguments = os.getenv('JUNIT_HIDE_TASK_ARGUMENTS', 'True').lower()