download-artifacts: only consider the most recent build

If the download-artifacts query returns more than one build, only
use the most recent one, as earlier builds may be for failed gate
runs and fetching them may fail.

Also, fix one more location which was missing an "artifacts/"
path prefix when returing artifacts.

Change-Id: If988d1f2bea863e0dad267359515018aae25ad45
This commit is contained in:
James E. Blair 2019-06-11 08:42:51 -07:00
parent 6d13ee475d
commit acbe2849da
3 changed files with 11 additions and 13 deletions

View File

@ -34,7 +34,7 @@
zuul: zuul:
artifacts: artifacts:
- name: "python_sdist" - name: "python_sdist"
url: "{{ item.path | basename }}" url: "artifacts/{{ item.path | basename }}"
metadata: metadata:
type: python_sdist type: python_sdist

View File

@ -1,8 +0,0 @@
- name: Download archive
uri:
url: "{{ artifact.url }}"
dest: "{{ download_artifact_directory }}"
loop: "{{ build.artifacts }}"
loop_control:
loop_var: artifact
when: "artifact.name == download_artifact_name or ((download_artifact_name | type_debug) == 'list' and artifact.name in download_artifact_name)"

View File

@ -2,8 +2,14 @@
uri: uri:
url: "{{ download_artifact_api }}/builds?{{ download_artifact_query }}" url: "{{ download_artifact_api }}/builds?{{ download_artifact_query }}"
register: build register: build
- name: Process build - name: Parse build response
loop: "{{ build.json }}" set_fact:
build: "{{ build.json[-1] }}"
- name: Download archive
uri:
url: "{{ artifact.url }}"
dest: "{{ download_artifact_directory }}"
loop: "{{ build.artifacts }}"
loop_control: loop_control:
loop_var: build loop_var: artifact
include_tasks: inner.yaml when: "artifact.name == download_artifact_name or ((download_artifact_name | type_debug) == 'list' and artifact.name in download_artifact_name)"