When retrieving the storage summary of repos in Artifactory, is there a way to order them by size?

Viewed 63
1 Answers

In this case, jq is your friend!

Pipe the output of the API to a jq with using the sort_by() functions.

Example:

curl -s -uadmin:password https://server/artifactory/api/storageinfo | jq '[.repositoriesSummaryList[] | {repoKey: .repoKey, itemsCount: .itemsCount, usedSpaceInBytes: .usedSpaceInBytes}] | sort_by(.usedSpaceInBytes)'

You can play around with the options.

Look for more details on the jq sorting in this good jq sorting doc.

Related