How do I delete old release builds? (“Max release builds”)

There are two categories to consider when we talk about deleting artifacts:  Handling artifacts that have already been deployed, and handling future deployments.

Handling the artifacts already deployed to Artifactory:

You can delete old builds by build number from the UI at artifacts tab → tree browser, right click on a repository’s name, or browse deeper to the folder from which you want to delete recursively, and choose ‘delete versions’, this will open a menu with all relevant build versions to delete, mark the ones you want to delete.

You can also delete builds by version from the REST API with the ‘Delete build’ query.

 

Handling future builds:

In order to utilize a mechanism that deletes older releases as the ‘max unique snapshots’ does for snapshot versions, you could write your own ‘user plugin’ which would do the following:

  • Intercept artifact-deployments to Artifactory with the ‘afterCreate’ hook
  • Check if the deployment artifacts are from the relevant build (check the build.name and build.number properties)
  • Run the cleanup accordingly.