Fix ansible & shell errors
Oh the joy of multi-step implement-run-debug situations like this...
Change-Id: Icf63ca02469f2ceb377b4ceb42bdc3004325dbd7
diff --git a/roles/fetch-artifacts-for-publish/tasks/main.yaml b/roles/fetch-artifacts-for-publish/tasks/main.yaml
new file mode 100644
index 0000000..5283d65
--- /dev/null
+++ b/roles/fetch-artifacts-for-publish/tasks/main.yaml
@@ -0,0 +1,26 @@
+- fail:
+ msg: "This role only works in the 'promote' pipeline."
+ when: zuul.pipeline != 'promote'
+
+- name: Ensure artifacts directory exists
+ delegate_to: localhost
+ file:
+ path: "{{ zuul.executor.work_root }}/artifacts"
+ state: directory
+
+- name: Collect artifacts
+ synchronize:
+ dest: "{{ zuul.executor.work_root }}/artifacts/"
+ mode: pull
+ src: "{{ zuul_output_dir }}/artifacts/"
+ verify_host: true
+
+- name: "Purge artifacts on the build node so that they are not uploaded the promote job's log directory"
+ file:
+ path: "{{ zuul_output_dir }}/artifacts/"
+ state: absent
+
+- name: "Re-create an empty artifacts directory on the build node so that `fetch-output` doesn't complain"
+ file:
+ path: "{{ zuul_output_dir }}/artifacts/"
+ state: directory