Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download the latest artifact from Artifactory repository?

I need the latest artifact (for example, a snapshot) from a repository in Artifactory. This artifact needs to be copied to a server (Linux) via a script.

What are my options? Something like Wget / SCP? And how do I get the path of the artifact?

I found some solutions which require Artifactory Pro. But I just have Artifactory, not Artifactory Pro.

Is it possible at all to download from Artifactory without the UI and not having the Pro-Version? What is the experience?

I'm on OpenSUSE 12.1 (x86_64) if that matters.

like image 297
user1338413 Avatar asked Dec 21 '12 11:12

user1338413


People also ask

How do I find the latest version of artifacts?

When trying to resolve the latest artifact version using the “Artifact Latest Version Search Based on Layout” REST API call, Artifactory will identify the version according to the configured layout of the repository.

How do I download from Artifactory in Python?

You can get the link from the UI if you browse to the file in the repository tree and copy the "URL to file". And get <file> locally. The same URL can be used by any curl library in python (or other languages).

How do I download JFrog artifacts from Jenkins?

install the plugin (https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin) on the job configuration page, enable "Generic Artifactory Integration". go to "Resolved Artifacts" and enter the artifacts to resolve/download - the question-mark icon on that page will tell you more about the syntax.


1 Answers

Something like the following bash script will retrieve the lastest com.company:artifact snapshot from the snapshot repo:

# Artifactory location server=http://artifactory.company.com/artifactory repo=snapshot  # Maven artifact location name=artifact artifact=com/company/$name path=$server/$repo/$artifact version=$(curl -s $path/maven-metadata.xml | grep latest | sed "s/.*<latest>\([^<]*\)<\/latest>.*/\1/") build=$(curl -s $path/$version/maven-metadata.xml | grep '<value>' | head -1 | sed "s/.*<value>\([^<]*\)<\/value>.*/\1/") jar=$name-$build.jar url=$path/$version/$jar  # Download echo $url wget -q -N $url 

It feels a bit dirty, yes, but it gets the job done.

like image 158
btiernay Avatar answered Sep 19 '22 11:09

btiernay