Franklin
Franklin

Reputation: 241

Deleting artifacts in artifactory

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?

Upvotes: 20

Views: 55596

Answers (2)

Dror Bereznitsky
Dror Bereznitsky

Reputation: 20376

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.

Upvotes: 27

Aleksey Burov
Aleksey Burov

Reputation: 49

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

Upvotes: 2

Related Questions