diff --git a/roles/download-artifact/README.rst b/roles/download-artifact/README.rst index 53bb197b4..a87098029 100644 --- a/roles/download-artifact/README.rst +++ b/roles/download-artifact/README.rst @@ -20,8 +20,16 @@ many artifacts as match the selection criteria. .. zuul:rolevar:: download_artifact_name + .. warning:: This field is deprecated and will be removed. Use + ``download_artifact_type`` instead. + The artifact name. This can be a string or a list of strings. +.. zuul:rolevar:: download_artifact_type + + The artifact type. This is the value of the ``type`` field in the + artifact metadata. This can be a string or a list of strings. + .. zuul:rolevar:: download_artifact_query :default: change={{ zuul.change }}&patchset={{ zuul.patchset }}&pipeline={{ download_artifact_pipeline }}&job_name={{ download_artifact_job }} diff --git a/roles/download-artifact/tasks/main.yaml b/roles/download-artifact/tasks/main.yaml index 0d5d7e6b8..c58a889e7 100644 --- a/roles/download-artifact/tasks/main.yaml +++ b/roles/download-artifact/tasks/main.yaml @@ -5,11 +5,23 @@ - name: Parse build response set_fact: build: "{{ build.json[0] }}" -- name: Download archive +- name: Download archive by name 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)" + when: + - "download_artifact_name is defined" + - "artifact.name == download_artifact_name or ((download_artifact_name | type_debug) == 'list' and artifact.name in download_artifact_name))" +- name: Download archive by type + uri: + url: "{{ artifact.url }}" + dest: "{{ download_artifact_directory }}" + loop: "{{ build.artifacts }}" + loop_control: + loop_var: artifact + when: + - "download_artifact_type is defined" + - "'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))"