Download artifact using REST API / Groovy

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Download artifact using REST API / Groovy

FWinkler

Hi,

 

I’m trying to download artifacts from our repository to a directory, again using groovy and the REST API. Could you please have a look at my code:

 

// uri was set by previous script part to

// "http://mic-build2.mic.co.at:8081/artifactory/features-qa-test-snapshot/at/mic/tariff/feature/at.mic.tariff.feature/20130320003416/at.mic.tariff.feature-20130320003416-win32.win32.x86.zip"

 

def server = new RESTClient()

server.headers['Authorization'] = 'Basic '+ (config.user + ':' + config.pwd).getBytes('iso-8859-1').encodeBase64()

def res =server.get(uri: "$uri")

 

Get seems to work but writes to the log:

WARNING: Cannot find parser for content-type: application/zip -- using default parser.

After execution the variable res contains a groovyx.net.http.HttpResponseDecorator@1a5e68a

res.contentType() is application/zip

 

So it seems that get works properly – but I’m missing something to get the get result as a zip file to my target directory. Unfortunately the documentation of <a href="http://wiki.jfrog.org/confluence/display/RTF/Artifactory%27s&#43;REST&#43;API#Artifactory%27sRESTAPI-RetrieveArtifact">Retrieve Artifact doesn’t help.

 

Thanks again for your help!

 

Kind regards!

Frank

 

 


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Artifactory-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/artifactory-users
Reply | Threaded
Open this post in threaded view
|

Re: Download artifact using REST API / Groovy

shayb
Hi Frank,

As you said, Artifactory returned a response that get works properly.
You can use the response data for whatever you like, for example, to save it:
//
new File("C://result.jar") << res.data
//


Regards.
Reply | Threaded
Open this post in threaded view
|

Re: Download artifact using REST API / Groovy

FWinkler
Hi Shay,

great, it worked! Thanks again for your help.

kind regards!
Frank
Reply | Threaded
Open this post in threaded view
|

Re: Download artifact using REST API / Groovy

hareeshabn
In reply to this post by shayb
Hi Shay,
Am new to artifactory.Can you help writing script for downloading all jars from artifactory as zip file.
Regards,
Hari