From acbe2849da1b74460de74304fc57207461bc6da2 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 11 Jun 2019 08:42:51 -0700 Subject: [PATCH] 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 --- playbooks/python/tarball-post.yaml | 2 +- roles/download-artifact/tasks/inner.yaml | 8 -------- roles/download-artifact/tasks/main.yaml | 14 ++++++++++---- 3 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 roles/download-artifact/tasks/inner.yaml diff --git a/playbooks/python/tarball-post.yaml b/playbooks/python/tarball-post.yaml index a95e85458..8efcc6c6f 100644 --- a/playbooks/python/tarball-post.yaml +++ b/playbooks/python/tarball-post.yaml @@ -34,7 +34,7 @@ zuul: artifacts: - name: "python_sdist" - url: "{{ item.path | basename }}" + url: "artifacts/{{ item.path | basename }}" metadata: type: python_sdist diff --git a/roles/download-artifact/tasks/inner.yaml b/roles/download-artifact/tasks/inner.yaml deleted file mode 100644 index a42cf3868..000000000 --- a/roles/download-artifact/tasks/inner.yaml +++ /dev/null @@ -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)" diff --git a/roles/download-artifact/tasks/main.yaml b/roles/download-artifact/tasks/main.yaml index 6f27e4dd8..0be75f6ba 100644 --- a/roles/download-artifact/tasks/main.yaml +++ b/roles/download-artifact/tasks/main.yaml @@ -2,8 +2,14 @@ uri: url: "{{ download_artifact_api }}/builds?{{ download_artifact_query }}" register: build -- name: Process build - loop: "{{ build.json }}" +- name: Parse build response + set_fact: + build: "{{ build.json[-1] }}" +- name: Download archive + uri: + url: "{{ artifact.url }}" + dest: "{{ download_artifact_directory }}" + loop: "{{ build.artifacts }}" loop_control: - loop_var: build - include_tasks: inner.yaml + loop_var: artifact + when: "artifact.name == download_artifact_name or ((download_artifact_name | type_debug) == 'list' and artifact.name in download_artifact_name)"