din ohayon
din ohayon

Reputation: 19

downloading files from artifactory to unix using python

I looked online and found sites like that: https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API

but couldn't simply just figured out how to simply give the script a URL and download the files to a giving path to a giving folder in the unix.

if anyone can just get me started it will be great.

Upvotes: -1

Views: 8153

Answers (2)

Djole
Djole

Reputation: 1

Something like this:

import subprocess

command = "curl -u<username>:<password> -T <target_file_path> <your_artifactory_repo/target_file>"
proc = subprocess.call(command, shell=True)

Upvotes: 0

Eldad Assis
Eldad Assis

Reputation: 11045

Every file stored in an Artifactory repository has a static link to it. Something like

https://<server>/artifactory/<repository>/<path-to-file>/<file>

You can get the link from the UI if you browse to the file in the repository tree and copy the "URL to file".

So you can curl for this file (and add auth if needed) like this:

curl -u name:password -O https://<server>/artifactory/<repository>/<path-to-file>/<file>

And get <file> locally.

The same URL can be used by any curl library in python (or other languages).

Upvotes: 2

Related Questions