From 7527689f1683552c01a7322629fa790ebd67ab3e Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Thu, 20 Jun 2024 14:57:04 +0200 Subject: [PATCH] [polarion] Merge xmls with junitparser In case there are multiple xml files that need to be reported to polarion, we need to merge them before passing them to jump. Using junitparser even in cases where there is only one xml file will have these benefits: * we don't have to write when conditions * the output xml will have the same structure - the content will be wrapped in tags whether we have more xml results or not - testsuite in junitparser context equals to one xml input. --- roles/polarion/tasks/main.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/roles/polarion/tasks/main.yml b/roles/polarion/tasks/main.yml index c6670ab66d..b1cb591715 100644 --- a/roles/polarion/tasks/main.yml +++ b/roles/polarion/tasks/main.yml @@ -63,6 +63,12 @@ state: latest # noqa: package-latest extra_args: --upgrade + - name: Install junitparser + ansible.builtin.pip: + name: junitparser + virtualenv: "{{ cifmw_polarion_jump_repo_dir }}/jump-venv" + state: latest # noqa: package-latest + - name: Use polarion-staging when: - cifmw_polarion_use_stage @@ -88,6 +94,13 @@ ansible.builtin.debug: var: pylero_output.stdout_lines + - name: Merge result XML files + ansible.builtin.shell: + chdir: "{{ cifmw_polarion_jump_result_dir }}" + cmd: >- + source "{{ cifmw_polarion_jump_repo_dir }}/jump-venv/bin/activate" && + junitparser merge {{ xml_files.files | json_query('[*].path') | join(' ') }} ./results_merged.xml + - name: Update Test Runs ansible.builtin.shell: chdir: "{{ cifmw_polarion_jump_repo_dir }}" @@ -95,10 +108,9 @@ source "{{ cifmw_polarion_jump_repo_dir }}/jump-venv/bin/activate" && {{ cifmw_polarion_jump_repo_dir }}/jump-venv/bin/python jump.py --testrun-id={{ cifmw_polarion_testrun_id }} - --xml-file={{ item.path }} + --xml-file={{ cifmw_polarion_jump_result_dir }}/results_merged.xml --update_testcases={{ cifmw_polarion_update_testcases | default(false) }} {{ cifmw_polarion_jump_extra_vars | default ('') }} - loop: "{{ xml_files.files }}" register: jump_script - name: Output of jump