diff --git a/roles/merge-output-to-logs/README.rst b/roles/merge-output-to-logs/README.rst new file mode 100644 index 000000000..3b0b6432e --- /dev/null +++ b/roles/merge-output-to-logs/README.rst @@ -0,0 +1,14 @@ +Put artifacts and docs into the executor log dir + +.. note:: + + This role only works in a trusted context. It is intended to + be used in the post playbook of a base job. + +This role moves artifacts and docs into the logs dir when +``zuul.change`` is defined so that they can be uploaded to the +log server for developer preview and validation. + +Artifacts and docs are left in place when ``zuul.change`` is +not defined so that normal publication jobs can publish them +to final locations. diff --git a/roles/merge-output-to-logs/tasks/main.yaml b/roles/merge-output-to-logs/tasks/main.yaml new file mode 100644 index 000000000..d1fa1116e --- /dev/null +++ b/roles/merge-output-to-logs/tasks/main.yaml @@ -0,0 +1,15 @@ +- name: Move artifacts and docs to logs dir + when: zuul.change is defined + delegate_to: localhost + shell: | + if ! $(ls {{ zuul.executor.work_root }}/{{ item }}) ; then + # Only create target directory if it is needed. + # Do not fail if it is already there. + mkdir -p {{ zuul.executor.log_root }}/{{ item }} + # Leave the original directory behind so that other roles + # operating on the interface directories can simply no-op. + mv -f {{ zuul.executor.work_root }}/{{ item }}/* {{ zuul.executor.log_root }}/{{ item }} + fi + loop: + - artifacts + - docs