Browse Source

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

Zuul 2 months ago
parent
commit
c87bc8b9df
2 changed files with 14 additions and 3 deletions
  1. 10
    0
      roles/stage-output/README.rst
  2. 4
    3
      roles/stage-output/tasks/main.yaml

+ 10
- 0
roles/stage-output/README.rst View File

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

+ 4
- 3
roles/stage-output/tasks/main.yaml View File

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

Loading…
Cancel
Save