Hi,

we're trying to use Artifactory for storing our build artifacts (snapshots and 
versions). The Jenkins plugin works properly and deploys the artifacts to the  
repositories.

To avoid our file system from running out of space I'm trying to write a Groovy 
script that deletes older artifacts and keeps only the last N artifacts of each 
of our modules. The interesting part of the script is:

def base.url = 'http://name:port'
def repo = 'my-repo'
def path = 'my-path'
def artifact = 'my-artifact'
def url.to.delete = base.url + '/artifactory/' + repo + '/' + path + '/' + 
artifact
print "url.to.delete = " + url.to.delete

def server = new RESTClient(base.url)
server.auth.basic('my-user', 'my-password')
def resp = server.delete(path: url.to.delete)

The delete statement causes this exception

groovyx.net.http.HttpResponseException: Forbidden

    at groovyx.net.http.RESTClient.defaultFailureHandler(RESTClient.java:240)

    at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:508)

    at groovyx.net.http.RESTClient.delete(RESTClient.java:196)

    at groovyx.net.http.RESTClient$delete.call(Unknown Source)

In the log I found: "[DENIED DELETE] repo:path/my-artifact.war for 
anonymous/... ".
I tried to give the anonymous user delete permissions and my script works fine. 
Of course that cannot be the solution...

I suppose that the problem is: "server.auth.basic('my-user', 'my-password')" 
but unfortunately I found no other (better) way to authentificate for the 
delete operation.

Thanks for your help in advance!

Regards!
Frank





------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Artifactory-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/artifactory-users

Reply via email to