Merge "Download-artifact: use the artifact type rather than name"

This commit is contained in:
Zuul 2019-07-29 16:14:47 +00:00 committed by Gerrit Code Review
commit c4aae4ffa5
2 changed files with 22 additions and 2 deletions

View File

@ -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 }}

View File

@ -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))"