Skip to content

Commit

Permalink
[custom_junit] Make the test prefix configurable via ini file and env…
Browse files Browse the repository at this point in the history
… var
  • Loading branch information
elfiesmelfie committed Oct 23, 2024
1 parent 12c154b commit 3e2d68f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion callback_plugins/custom_junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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()
Expand Down

0 comments on commit 3e2d68f

Please sign in to comment.