Update download-artifact to use zuul.artifacts

Also support the ability for child_jobs to fetch artifacts.

Change-Id: I0e2d43873410a095771503da712e67db5b64f25f
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2019-11-25 22:21:29 -05:00
parent 26cadea6af
commit 77b5d76112
1 changed files with 25 additions and 7 deletions

View File

@ -1,15 +1,33 @@
---
- name: Query inventory for artifact information
block:
- name: Parse inventory response
set_fact:
_artifacts: "{{ zuul.artifacts }}"
when: zuul.artifacts is defined
- name: Query Zuul API for artifact information
uri:
url: "{{ download_artifact_api }}/builds?{{ download_artifact_query }}"
register: build
- name: Parse build response
set_fact:
build: "{{ build.json[0] }}"
block:
- name: Fetch info from Zuul API
uri:
url: "{{ download_artifact_api }}/builds?{{ download_artifact_query }}"
register: build
- name: Parse build response
set_fact:
_artifacts: "{{ build.json[0].artifacts }}"
when: download_artifact_api is defined
- name: Ensure artifacts directory exists
file:
path: "{{ download_artifact_directory }}"
state: directory
- name: Download archive by type
uri:
url: "{{ artifact.url }}"
dest: "{{ download_artifact_directory }}"
loop: "{{ build.artifacts }}"
loop: "{{ _artifacts }}"
loop_control:
loop_var: artifact
when: "'metadata' in artifact and 'type' in artifact.metadata and (artifact.metadata.type == download_artifact_type or ((download_artifact_type | type_debug) == 'list' and artifact.metadata.type in download_artifact_type))"