Continuous Automation: DevOps • Agile • Leadership • Business Innovation: What the hell happened?
Continuous Automation: DevOps • Agile • Leadership • Business Recovering from Failure
Continuous Automation: DevOps • Agile • Leadership • Business You’re living in a buzzword world

Artifactory Retention Policy – Automating removal of stale artifacts


Managing un-released or outdated artifacts is a necessary exercise to ensure proper scalability of an artifact management system.  The professional version of Artifactory has plugins which can assist with this but the open source version does not. To prevent the system from growing exponentially Artifacts need to be managed and removed if no longer deemed needed. To facilitate this I typically implement four repositories for each logical division of an artifact type:

  1. foo.development
  2. foo.production
  3. foo.promoted
  4. foo.released

Each repository has a different retention policy increasing in length as the repository is closer to “released” status. For example:

  • Development – 30 days
  • Production – 90 days
  • Promoted – 180 days
  • Released – Infinity

Artifacts deployed into a given repository are promoted up the chain until either released or rejected. This system helps define the length of time the artifact will live in a given repository. It also provides a digital sign-off system which can be used to track who in the organization signed off on a given release and what quality gates were verified.


To architect the retention system there is really two functions in our script which will need to be developed against the Artifactory REST API:

  • Search an Artifactory repository for outdated Artifacts
  • Delete the outdated artifacts that were located

NOTE: Artifactory stores its artifacts creation time in EPOCH time.

First Function Example (Search for artifacts to delete in a given repository)

Function Example 2 (Delete matching items based found in the search above)

Function 3 (Helper Function to call ‘Kick-Off’ the automation)

This function will iterate through a list of repositories and call the function:

Putting it All together (FINAL Script):



In researching this subject a while back I came across a few examples but none were clear enough to provide a significant benefit. Hopefully this will help the community better understand how to utilize Artifactory’s intuitive REST API and adapt it for their organizations needs.

[Total: 0    Average: 0/5]

Category: Engineering

Share this Article


  1. Hi,
    This seems like what I am looking for. Sorry, can you please shed some more light as what language this is and how to run it?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Article by: jmcallister