Deleting artifacts in artifactory
Asked Answered
K

2

20

I want to delete artifacts in artifactory.I googled and found this link https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API

Here the Delete build,using REST API,is what we are going for at the moment.Can any one give me a general idea how the command should look using curl command.Also in buildname what do i need to specify?

Kavanaugh answered 1/3, 2016 at 12:25 Comment(0)
D
27

For deleting a single artifact or folder you should use the Delete Item API, for example

curl -u admin:password -X DELETE http://localhost:8080/artifactory/libs-release-local/ch/qos/logback/logback-classic/0.9.9

Notice that you will need a user with delete permissions.
If all goes well you should expect a response with a 204 status and no content.

The delete API is intended for deleting build information and is relevant if you are using the Artifactory build integration.

Damage answered 2/3, 2016 at 7:58 Comment(3)
I received HTTP/1.1 405 Method Not Allowed. Allow: OPTIONS, GET, HEAD, POSTFrontlet
Put a space after "-u" and "-X" in order to work, i.e., curl -u admin:password -X DELETE .Tomika
I use this command but i got not found error.Thermopile
F
1

Nowadays there's a tool that can be used for it (note that I am a contributor to that tool):

https://github.com/devopshq/artifactory-cleanup

Assume i have 10 repositories and i want to keep only last 20 artifacts in 5 repositories and unlimited in other 5 repositories

The rule for 10 repositories would look like:

# artifactory-cleanup.yaml
artifactory-cleanup:
  server: https://repo.example.com/artifactory
  # $VAR is auto populated from environment variables
  user: $ARTIFACTORY_USERNAME
  password: $ARTIFACTORY_PASSWORD

  policies:
    - name: reponame
      rules:
        - rule: Repo
          name: "reponame"
        - rule: KeepLatestNFiles
          count: 20
Frenzied answered 5/9, 2022 at 13:41 Comment(4)
When linking to a website, blog or repo to which you have affiliation, you must explicitly disclose your involvement. Otherwise, your post may be flagged as spam.Brannen
@AdrianMole hi, thank you for the note, didn't know that rule! Is there a special flag for it in SO or I just should have mentioned like "I've contributed in the tool"?Frenzied
Something like what I have just edited in will normally suffice. I don't actually think you are a spammer, but this article may be of some help.Brannen
@AdrianMole thank you for your work and the advice, appreciate it! I'm not a spammer, rather a newbie, but we behave the same sometimes...Frenzied

© 2022 - 2024 — McMap. All rights reserved.