2024-12-12 11:53:34 +07:00
|
|
|
# Tải artifact từ Nexus
|
|
|
|
|
- name: Download artifact from Nexus
|
|
|
|
|
win_get_url:
|
|
|
|
|
url: "{{ nexus_url }}/{{ artifact_name }}"
|
|
|
|
|
dest: "{{ temp_dir }}\\{{ artifact_name }}"
|
|
|
|
|
validate_certs: no
|
|
|
|
|
url_username: "{{ nexus_username }}"
|
|
|
|
|
url_password: "{{ nexus_password }}"
|
|
|
|
|
register: download_status
|
|
|
|
|
vars:
|
|
|
|
|
nexus_url: "{{ nexus_url }}"
|
|
|
|
|
artifact_name: "{{ artifact_name }}"
|
|
|
|
|
nexus_username: "{{ nexus_username }}"
|
|
|
|
|
nexus_password: "{{ nexus_password }}"
|
|
|
|
|
|
2024-12-23 00:23:40 +07:00
|
|
|
# Debug download_status
|
|
|
|
|
- name: Debug download_status
|
|
|
|
|
debug:
|
|
|
|
|
var: download_status
|
|
|
|
|
|
|
|
|
|
- name: Check if the download was successful
|
|
|
|
|
debug:
|
2024-12-23 00:27:39 +07:00
|
|
|
msg: "Download successful: {{ download_status.msg }}"
|
2024-12-23 00:23:40 +07:00
|
|
|
|
|
|
|
|
# Kiểm tra ở trên server đã tồn tại file vùa tải xuống không
|
|
|
|
|
- name: Check if the artifact file exists
|
|
|
|
|
stat:
|
|
|
|
|
path: "{{ temp_dir }}\\{{ artifact_name }}"
|
|
|
|
|
register: file_status
|
|
|
|
|
changed_when: false
|
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
|
|
# Debug file_status
|
2024-12-23 00:27:39 +07:00
|
|
|
- name: Debug file_status
|
2024-12-23 00:23:40 +07:00
|
|
|
debug:
|
2024-12-23 00:27:39 +07:00
|
|
|
var: file_status
|
2024-12-23 00:23:40 +07:00
|
|
|
|
2024-12-12 11:53:34 +07:00
|
|
|
|
|
|
|
|
# Giải nén artifact vào thư mục target
|
|
|
|
|
- name: Deploy Backend to target environment
|
|
|
|
|
win_unzip:
|
|
|
|
|
src: "{{ temp_dir }}\\{{ artifact_name }}"
|
|
|
|
|
dest: "{{ target_path }}"
|
|
|
|
|
overwrite: yes
|
|
|
|
|
|