diff --git a/.zuul.yaml b/.zuul.yaml index 7165ad6..7dbfed5 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -21,6 +21,7 @@ parent: opendev-build-docker-image allowed-projects: zuul/zuul-registry run: playbooks/functional-test/run.yaml + post-run: playbooks/functional-test/post.yaml vars: &image_vars docker_images: - context: . @@ -33,6 +34,7 @@ description: Build and test a Docker image and upload to Docker Hub. allowed-projects: zuul/zuul-registry run: playbooks/functional-test/run.yaml + post-run: playbooks/functional-test/post.yaml secrets: name: docker_credentials secret: zuul-registry-dockerhub diff --git a/playbooks/functional-test/post.yaml b/playbooks/functional-test/post.yaml new file mode 100644 index 0000000..977ecea --- /dev/null +++ b/playbooks/functional-test/post.yaml @@ -0,0 +1,17 @@ +- hosts: all + tasks: + - name: List containers + command: "docker ps -a --format '{{ '{{ .Names }}' }}'" + register: docker_containers + ignore_errors: true + + - name: Create container log dir + file: + path: "{{ ansible_user_dir }}/zuul-output/logs/docker" + state: directory + + - name: Save container logs + loop: "{{ docker_containers.stdout_lines | default([]) }}" + shell: "docker logs {{ item }} &> {{ ansible_user_dir }}/zuul-output/logs/docker/{{ item }}.txt" + args: + executable: /bin/bash