Artifactory getStats always returns null object

  artifactory, docker, restapi

I am trying to get the download statistics of a docker image we host on our own artifactory server in a groovy plugin on the server.
So far it looks like the manifest.json file has the statistics I am looking for.

repositories.getStats(RepoPath) should return a StatsInfo object which has getDownloadCount().

However, no matter what I pass to repositories.getStats() it always returns a null object.

I’ve tried:

  • docker-local
  • docker-local/ai
  • docker-local/ai/latest
  • docker-local/ai/latest/manifest.json

But still repositories.getStats() return a null object.

I would expect the following to work:

def stats = repositories.getStats(RepoPathFactory.create('docker-local','ai/latest/manifest.json'))
def dlCount = stats.getDownloadCount()

But it keeps returning the error:

"Cannot invoke method getDownloadCount() on null object"

Calling ?stats on the manifest.json through the REST API works and it returns a json formatted string with the download statistics. Ex:

  "uri" : "",

  "downloadCount" : 10,

  "lastDownloaded" : 1593160404880,

  "lastDownloadedBy" : "Peter Griffin",

  "remoteDownloadCount" : 0,

  "remoteLastDownloaded" : 0

What am I doing wrong?

Source: Docker Questions