
Adds a role to let users define a manifest of artifacts located in zuul-output/artifacts that should be uploaded to pre defined artifactory instances. Change-Id: I00dc0302e85ce59b3808f6e62e2bcdadf2e41fde
70 lines
2.7 KiB
YAML
70 lines
2.7 KiB
YAML
- name: Make sure artifact exists on the executor
|
|
stat:
|
|
path: "{{ _undocumented_test_work_dir_ | default(zuul.executor.work_root) }}\
|
|
/artifacts/{{ zj_artifact.src }}"
|
|
register: artifact
|
|
delegate_to: "{{ _undocumented_test_worker_node_ | default('localhost') }}"
|
|
failed_when: not artifact.stat.exists
|
|
|
|
- name: Get sha256 checksum
|
|
stat:
|
|
path: "{{ _undocumented_test_work_dir_ | default(zuul.executor.work_root) }}\
|
|
/artifacts/{{ zj_artifact.src }}"
|
|
checksum_algorithm: sha256
|
|
delegate_to: "{{ _undocumented_test_worker_node_ | default('localhost') }}"
|
|
register: artifact_sha256_checksum
|
|
|
|
- name: Set request header fact
|
|
set_fact:
|
|
request_header:
|
|
X-Checksum-Sha1: "{{ artifact.stat.checksum }}"
|
|
X-Checksum-Sha256: "{{ artifact_sha256_checksum.stat.checksum }}"
|
|
|
|
- name: Add artifact headers
|
|
set_fact:
|
|
request_header: "{{ request_header | combine(zj_artifact.headers|default({})) }}"
|
|
|
|
- name: Add api key to header
|
|
when: "'api_key' in upload_artifactory_instance[zj_artifact.instance]"
|
|
no_log: true
|
|
set_fact:
|
|
request_header: "{{ request_header |
|
|
combine({'X-JFrog-Art-Api': upload_artifactory_instance[zj_artifact.instance].api_key}) }}"
|
|
|
|
- name: Set artifactory password
|
|
no_log: true
|
|
set_fact:
|
|
_artifactory_password: "{{ upload_artifactory_instance[zj_artifact.instance].password }}"
|
|
when:
|
|
- "'api_key' not in upload_artifactory_instance[zj_artifact.instance]"
|
|
- "'password' in upload_artifactory_instance[zj_artifact.instance]"
|
|
|
|
- name: Set artifactory url fact
|
|
set_fact:
|
|
_artifactory_url: "{{ upload_artifactory_instance[zj_artifact.instance].transport | default('https') }}://\
|
|
{{ upload_artifactory_instance[zj_artifact.instance].fqdn }}\
|
|
/artifactory/{{ zj_artifact.dest }}"
|
|
|
|
- name: Upload artifact
|
|
uri:
|
|
user: "{{ upload_artifactory_instance[zj_artifact.instance].user }}"
|
|
password: "{{ _artifactory_password | default(omit) }}"
|
|
url: "{{ _artifactory_url }}"
|
|
src: "{{ _undocumented_test_work_dir_ | default(zuul.executor.work_root) }}/artifacts/{{ zj_artifact.src }}"
|
|
headers: "{{ request_header }}"
|
|
status_code: 201
|
|
method: PUT
|
|
force_basic_auth: "{{ upload_artifactory_instance[zj_artifact.instance].force_basic_auth |
|
|
default(false) | bool }}"
|
|
remote_src: yes # To not unecessarily copy artifact to a tempfile
|
|
delegate_to: "{{ _undocumented_test_worker_node_ | default('localhost') }}"
|
|
|
|
- name: Add artifact link to build page
|
|
zuul_return:
|
|
data:
|
|
zuul:
|
|
artifacts:
|
|
- name: "{{ zj_artifact.name }}"
|
|
url: "{{ _artifactory_url }}"
|
|
metadata: "{{ zj_artifact.metadata | default(omit) }}"
|