How to Use Artifactory Query Language (AQL) to Obtain Data from an Archive

Ino Choi
2022-05-15 12:02

Artifactory features default-enabled capabilities, known asprimary Domains, which can assist you in searching for data in Artifactory. One of these domains, calledArchive, allows you to browse the contents of archived artifacts (and can be altered by editing the archive MIME-type in themimetypes.xmlfile, which is located in the$ARTIFACTORY_HOME/etc/).

Here's an example: Let’s say you'd like to get a file from inside of Archive. Instead of downloadingArchivein its entirety, you'd simply search its contents for thefile you wantto see if it's there by doing the following:curl -XPOST -u /artifactory/api/search/aql -H "Content-type: text/plain" -d
'archive.entries.find (
{
"archive.item.repo":{"$eq":""},
"archive.item.name":{"$eq":""}
}
)'
If you find what you're looking for, download only that file by using theArchive Entry DownloadREST API.

However, when the primary domain isarchive, a non-admin user will not be able to perform this AQL search. Using the example above, if a non-admin user attempts to perform an archive.entries.find the output will yield no results:{
"results" : [ ],
"range" : {
"start_pos" : 0,
"end_pos" : 0,
"total" : 0
}

In this case, the non-admin user will have to use theitemsprimary domain and add theincludetag to obtain similar information:curl -XPOST -u /artifactory/api/search/aql -H "Content-type: text/plain" -d 'items.find ({"name":{"$eq":""}}).include("archive.entry")'