Ensure output dirs are empty

Change-Id: I813ecc32c9781091dc7faf67dcc99dfe88bbaa5d
This commit is contained in:
Albin Vass 2020-05-12 11:54:23 +02:00
parent 1ab22a3b44
commit 00d758af26
3 changed files with 42 additions and 1 deletions

View File

@ -1,4 +1,4 @@
Ensure output directories are in place
Ensure output directories are in place and are empty.
**Role Variables**

View File

@ -1,3 +1,14 @@
- name: Empty Zuul Output directories by removing them
file:
path: "{{ zuul_output_dir }}/{{ zj_output_dir }}"
state: absent
with_items:
- logs
- artifacts
- docs
loop_control:
loop_var: zj_output_dir
- name: Ensure Zuul Output directories exist
file:
path: "{{ zuul_output_dir }}/{{ zj_output_dir }}"

View File

@ -30,3 +30,33 @@
- artifact_directory is succeeded
- doc_directory is not changed
- doc_directory is succeeded
- name: Add a logfile, artifact, and doc item
file:
path: "{{ zuul_output_dir }}/{{ item }}/file.txt"
state: touch
loop:
- docs
- artifacts
- logs
- name: Run ensure-output-dirs
include_role:
name: ensure-output-dirs
- name: Make sure output dirs were emptied
file:
path: "{{ zuul_output_dir }}/{{ item }}/file.txt"
state: absent
register: output_items
loop:
- docs
- artifacts
- logs
- name: Validate that files were removed in ensure-output-dirs
loop: "{{ output_items.results }}"
assert:
that:
- item is not changed
- item is succeeded