Using the Artifactory REST API to deploy a jar file

Given this api documentation , how can I use HTTPBuilder and Groovy to build my request? I tried a few things, but I do not understand.

def http = new HTTPBuilder() http.request('http://artifactory:8888/libs-snapshot-local/my/jar/1.0/test-jar-1.0.jar', PUT, JSON ) { req -> body = [ uri: "http://artifactory:8888/libs-snapshot-local/my/jar/1.0/test-jar-1.0.jar", downloadUri: "http://artifactory:8888/libs-snapshot-local/my/jar/1.0/test-jar-1.0.jar", repo: "libs-snapshot-local", path: "c:\\pathtojarfile\\test.jar", created: "2012-02-03T08:37:12.599-0800", createdBy: "someuser", size: "1024", mimeType: "application/java-archive" ] response.success = { resp, json -> } } 

This seems to help me in part, but it loads an empty jar file. It seems that the body is completely ignored. Removing this result leads to the same result. I can not find a good link to how this is done.

+7
source share
1 answer

The JSON in the specified documentation is actually an Artifactory response for a deployment request.
For deployment, Artifactroy requires only a simple PUT request, for example:

 def restClient = new RESTClient('http://localhost:8080/artifactory/libs-release-local/') restClient.auth.basic 'username', 'password' restClient.encoder.'application/zip' = this.&encodeZipFile def encodeZipFile(Object data) throws UnsupportedEncodingException { def entity = new FileEntity((File) data, 'application/zip'); entity.setContentType('application/zip'); return entity } def response = restClient.put(path: 'org/artifact/1.0/artifact-1.0.jar', body: new File('/path/to/local/artifact.jar'), requestContentType: 'application/zip' ) 
+13
source

All Articles