Collect docker logs in functional test
If any containers are still running at the end of the test, collect their logs. Change-Id: I9d667e646f2a37a63bf6c311b511e567bb3f153c
This commit is contained in:
parent
0f76a0a09d
commit
d97cd6ccf7
@ -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
|
||||
|
17
playbooks/functional-test/post.yaml
Normal file
17
playbooks/functional-test/post.yaml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user