ARTIFACTORY: Using Workers to Set Custom Repository Level Usage Data as a Property

ARTIFACTORY: Using Workers to Set Custom Repository Level Usage Data as a Property

Products
Frog_Artifactory
Content Type
User_Guide
AuthorFullName__c
Benjamin Katz
articleNumber
000006813
FirstPublishedDate
2025-12-31T10:30:26Z
lastModifiedDate
2025-12-31
Introduction 

Many organizations may find it useful to track Artifactory usage on a repository level. No two  use cases are exactly the same. Here we will implement one use case of tracking the last time any item was downloaded from a repository. This method can be used as a jumping off point for further custom made solutions that fit your organization’s needs.

This solution will provide us with a repository level property with a timestamp of the last time an artifact was downloaded from that repository.

User-added image 

Guide

To get started, ensure workers are set up in the environment. For general details on workers and installation, please refer to our documentation.

Once workers are installed and configured, we can create a new event driven worker ‘After Download’. Please see ‘After Download’ worker example here.

User-added image 

We can use the linked sample code and modify it to better fit our use case.

Instead of doing an Artifactory ping, we can add a property to the repository using the Set Property API:
const now = Date.now();
const repo = data.metadata.repoPath.key;
const res = await context.clients.platformHttp.put(`/artifactory/api/storage/${repo}?properties=last_downloaded_repo=${now}&recursive=0`);

 

These three lines of code get the current time, get the repository that the user just downloaded from, and set a property on that repository noting the most recent download timestamp.

We can then add the repositories in the worker settings that we would like the worker to apply to:

User-added image 

Now, after downloading an artifact from a repository, we will see the repository level property update to the current timestamp (refer to the image in the introduction).

We can apply this same method to further customize properties based on Artifactory events to better track usage. For more information regarding worker capabilities, please see our documentation here: https://jfrog.com/help/r/jfrog-platform-administration-documentation/workers.