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.
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.
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With