0
votes

Need to download latest war file from Artifactory using get_url method in ansible.

- name: Download war file from artifactory
 get_url:
   url: http://localhost:5040/artifactory/webapp/#/artifacts/browse/tree/General/libs-snapshot-local/devops/ilp1/ILP/0.0.1-SNAPSHOT/ILP-0.0.1-20200408.072920-1.war
   dest: /home/osgdev/devops_capstone/testnew/ILP_BookStoreWorkspace/roles/ansi  

Below the code which i have tried.

 name: Download war file from artifactory
 get_url:
   url: http://localhost:5040/artifactory/libs-snapshot-local/devops/ilp1/ILP/0.0.1-SNAPSHOT/latest.war
   dest: /home/osgdev/devops_capstone/testnew/ILP_BookStoreWorkspace/roles/ansicode here

Getting the below message: TASK [ansi : Download war file from artifactory] *********************************************************************************************************************************************************** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named lxml fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_NrEV35/ansible_module_maven_artifact.py\", line 158, in \n from lxml import etree\nImportError: No module named lxml\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0} to retry, use: --limit @/home/osgdev/devops_capstone/testnew/ILP_BookStoreWorkspace/roles/ansi/ansi.retry

PLAY RECAP ************************************************************************************************************************************************************************************************* localhost : ok=3 changed=0 unreachable=0 failed=1

I have 2 or more files is there, but i need to download the latest war file

ILP-0.0.1-20200408.072920-1.war ILP-0.0.1-20200410.071653-2.war

Please help on this.

1
You have failed to specify what you have already tried, and what error message it is producing for you. Please read the how to ask page, and pay especial attention to the MCVE section - mdaniel
Below the code i have tried - Karthika

1 Answers

0
votes

The Artifactory REST API supports downloading the latest Maven version for both releases and snapshots.
For snapshots you should use the following format in the Ansible url field:

http://localhost:8081/artifactory/ivy-local/org/acme/1.0-[SNAPSHOT]/acme-1.0-[SNAPSHOT].jar

For releases you should use the following format:

http://localhost:8081/artifactory/ivy-local/org/acme/[RELEASE]/acme-[RELEASE].jar