Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
Column
width75%

Overview

Artifactory Query Language (AQL) is specially designed to find artifacts stored within Artifactory's local repositories and remote repository caches based on any number of search criteria. Its syntax offers a simple way to formulate complex queries that specify any number of search criteria, filters, sorting options, and field output parameters. AQL is exposed as a RESTful API which, when possible, uses data streaming to provide output data resulting in extremely fast response times and low memory consumption.

Here are a couple of examples that show the power of AQL.

Example 1:

Return all artifacts of the "artifactory" build whose license is not an Apache license.

Code Block
languagejs
items.find
(
	{
    	"$and":
		[
        	{"@build.name":{"$eq":"artifactory"}},
            {"@artifactory.licenses":{"$nmatch":"Apache-*"}}
        ]
	}
)

Example 2:

Return all artifacts of the "artifactory" build that has been downloaded more than 100 times during the month of January 2014.

Display the artifact name, its repository, its path in the repository and the number of times it was downloaded

Code Block
languagejs
items.find
(
	{
    	"$and":
		[
        	{"@build.name":{"$eq":"artifactory"}},
            {"stat.downloads":{"$gt":100}},
            {"stat.downloaded":{"$gte":"2014-01-01"}},
            {"stat.downloaded":{"$lt":"2014-02-01"}}
        ]
    }
).include("name","repo","path","stat.downloads")
Column
Info
iconfalse
titlePage Contents

Table of Contents
maxLevel3

...

Code Block
//This example shows both an implicit "$and" operator (since this is the default, you don't have expressly specify it, but rather separate the criteria by a comma), and an explicit "$or" operator. 
//Find all items that are files and are in either the jcenter-cache or my-local repositories. 
items.find({"type" : "file","$or":[{"repo" : "jcenter-cache", "repo" : "my-local" }]})

//Find all the items that are either in a repository called "debian" and whose name ends with ".deb" or are in a repository called "yum" and whose name ends with ".rpm".
items.find(
	{
		"$or":
		[
			{
				"$and":
				[
					{"repo" : "debian"} ,
					{"name" : {"$match" : "*.deb"}}
				]
			}, 
			{
				"$and":
				[
					{"repo" : "yum"} ,
					{"name" : {"$match" : "*.rpm"}}
				]
			}
		]
	}
)
  
//Find all items in a repository called "my_local", and that have a property with a key called "license" and value that is any variant of "LGPL".
items.find({"repo" : "my_local"},{"@artifactory.licenses" : {"$match" : "*LGPL*"}})

...