Merge "stage-output: Add the ability to add .txt extensions to files"

This commit is contained in:
Zuul 2019-02-02 07:18:51 +00:00 committed by Gerrit Code Review
commit c87bc8b9df
2 changed files with 14 additions and 3 deletions

View File

@ -23,6 +23,16 @@ intended to be used before output fetching in a base job's post-playbook.
null overrides the will of a parent job to copy something instructing
not to copy.
If the type is suffixed with ``_txt``, then the item will have
``.txt`` appended to its name. For example::
.. code-block:: yaml
zuul_copy_output:
/var/log/syslog: logs_txt
Will copy ``/var/log/syslog`` to ``logs/syslog.txt``.
.. zuul:rolevar:: stage_dir
:default: {{ ansible_user_dir }}

View File

@ -27,12 +27,13 @@
# NOTE(andreaf) Files or folders that start with a '.' are renamed to starting
# with an '_' else they would not be visible in the logs folder once uploaded.
# Extension changes are handled later via find as we want to rename files
# included of folders specified in `zuul_copy_output`.
# included of folders specified in `zuul_copy_output` (except for logs_txt,
# which is handled here).
- name: Set source and destination for files and folders
set_fact:
source: "{{ item.stat.path }}"
dest: "{{ item.item.value }}/{{ item.stat.path|basename|regex_replace('^(\\..*)$', '_\\1') }}"
type: "{{ item.item.value }}"
dest: "{{ item.item.value.split('_')[0] }}/{{ item.stat.path|basename|regex_replace('^(\\..*)$', '_\\1') }}{% if item.item.value.endswith('_txt') %}.txt{% endif %}"
type: "{{ item.item.value.split('_')[0] }}"
with_items: "{{ sources.results }}"
when:
- item.stat.exists