Add download artifact role
This role can be used to download a previously built artifact. Requires a Zuul API endpoint. Change-Id: I5dd88f67bfa383f5f2bc0cfcc3b2346def796ae7
This commit is contained in:
parent
189c2471ec
commit
fc62f6f36b
28
roles/download-artifact/README.rst
Normal file
28
roles/download-artifact/README.rst
Normal file
@ -0,0 +1,28 @@
|
||||
Download an artifact from a completed build of a Zuul job
|
||||
|
||||
Given a change downloads an artifact from a previous build (by default
|
||||
of the current change) into the work directory.
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: download_artifact_api
|
||||
|
||||
The Zuul API endpoint to use. Example: ``https://zuul.example.org/api/tenant/{{ zuul.tenant }}``
|
||||
|
||||
.. zuul:rolevar:: download_artifact_pipeline
|
||||
|
||||
The pipeline in which the previous build ran.
|
||||
|
||||
.. zuul:rolevar:: download_artifact_job
|
||||
|
||||
The job of the previous build.
|
||||
|
||||
.. zuul:rolevar:: download_artifact_name
|
||||
|
||||
The artifact name.
|
||||
|
||||
.. zuul:rolevar:: download_artifact_query
|
||||
:default: change={{ zuul.change }}&patchset={{ zuul.patchset }}&pipeline={{ download_artifact_pipeline }}&job_name={{ download_artifact_job }}
|
||||
|
||||
The query to use to find the build. This should return exactly one
|
||||
result. Normally the default is used.
|
2
roles/download-artifact/defaults/main.yaml
Normal file
2
roles/download-artifact/defaults/main.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
download_artifact_query: "change={{ zuul.change }}&patchset={{ zuul.patchset }}&pipeline={{ download_artifact_pipeline }}&job_name={{ download_artifact_job }}"
|
11
roles/download-artifact/tasks/main.yaml
Normal file
11
roles/download-artifact/tasks/main.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
- name: Query Zuul API for artifact information
|
||||
uri:
|
||||
url: "{{ download_artifact_api }}/builds?{{ download_artifact_query }}"
|
||||
register: build
|
||||
- name: Extract artifact URL
|
||||
set_fact:
|
||||
archive_url: "{{ (build.json[0].artifacts | selectattr('name', 'equalto', download_artifact_name) | list)[0].url }}"
|
||||
- name: Download archive
|
||||
uri:
|
||||
url: "{{ archive_url }}"
|
||||
dest: "{{ zuul.executor.work_root }}"
|
Loading…
Reference in New Issue
Block a user