Albin Vass 9062289151 Check for loop_control in with_ type loops
Change-Id: I191265df7709a6262b44a428d78fe28ffaeb4b75
2020-05-01 13:45:34 +02:00

65 lines
1.6 KiB
YAML

# Sphinx might build multiple PDF files, for example for graphic files
# to include. We only want to grab the end result and not any such
# input files.
- name: Check for PDF file names
stat:
path: "{{ zuul_work_dir }}/{{ sphinx_build_dir }}/pdf/{{ zj_sphinx_pdf }}"
get_checksum: false
get_mime: false
get_md5: false
with_items: "{{ sphinx_pdf_files }}"
loop_control:
loop_var: zj_sphinx_pdf
register: pdf_file_stat
- name: Set pdf_files_found to default
set_fact:
pdf_files_found: false
- name: Check if any file found
set_fact:
pdf_files_found: true
when: zj_pdf.stat.exists
with_items: "{{ pdf_file_stat.results }}"
loop_control:
loop_var: zj_pdf
# Now loop...
- name: Grab PDF files
when: pdf_files_found
block:
- name: Create PDF directory
delegate_to: localhost
file:
path: "{{ zuul.executor.log_root }}/pdf"
state: directory
- name: Fetch PDF files
synchronize:
dest: "{{ zuul.executor.log_root }}/pdf/{{ item.item }}"
mode: pull
src: "{{ item.stat.path }}"
verify_host: true
with_items: "{{ pdf_file_stat.results }}"
loop_control:
loop_var: zj_pdf
when: item.stat.exists
- name: Return PDF artifact to Zuul
zuul_return:
data:
zuul:
artifacts:
- name: "Docs PDF: {{ zj_pdf.item }}"
url: "pdf/{{ zj_pdf.item }}"
metadata:
type: docs_pdf
with_items: "{{ pdf_file_stat.results }}"
loop_control:
loop_var: zj_pdf
when: item.stat.exists