Automatically Clean Artifactory Artifacts

If you’re running into issues with artifacts taking up too much space on your Artifactory server, this will set you up with a programmatic way to clean old artifacts as they are no longer required.

Install ArtifactCleanup Plugin

SSH into the Artifactory server, go into the $JFROG_HOME/etc/plugins directory and run the following to download the Artifact Cleanup plugin:

wget https://raw.githubusercontent.com/jfrog/artifactory-user-plugins/master/cleanup/artifactCleanup/artifactCleanup.groovy
wget https://raw.githubusercontent.com/jfrog/artifactory-user-plugins/master/cleanup/artifactCleanup/artifactCleanup.json

Make changes to the artifactCleanup.json file based on desired behavior.

To enable logging, add the following to $ARTIFACTORY_HOME/etc/logback.xml:

<logger name="artifactCleanup">
    <level value="info"/>
</logger>

Restart the server to install the plugin and get it set up for processing.

Invoking Manually

Read more information on executing cleanup manually on the GitHub page. It’s worth running as a dry-run and making sure functionality works as intended before letting loose.

After running, you can check the logs $ARTIFACTORY_HOME/logs/artifactory.log to find the results of cleanup.

Remember that once deleted using the plugin, the artifacts will remain in the Trash Can if it is enabled on your instance.

Leave a Reply

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