I would like to fetch all artifact name and their versions which are under specific group using AQL. Can you please help with the API endpoint and AQL.
Below the GET REST API gets me the versions related to runner on group com.load.runners. But I like to get all the artifacts and their versions from group com.load.runners.
https://localhost/artifactory/api/search/versions?g=com.load.runners&a=runner&repos=maven
There seems to be no direct way which is simple and performant enough to do that using AQL.
BUT-
What you can do is use prior knowledge on the Maven layout (how Maven artifacts are stored in the repository), use AQL to query for relevant items (files), and then extract the information you need.
Relying on
*.pom
files (since every artifact version has exactly one) in the Maven layout (where a.
is replaced with a/
):For example, the path to the
.pom
file of the artifactcom.load.runners:runners:1.0.0
will be:With this knowledge you can run the following query:
This will return the paths of all the
.pom
files, without the files name. For example:So now, all you have to do is to extract the information from these paths - split by
/
where the last part is theversion
(e.g.1.0.0
), the one before last is theartifactId
(e.g.runner
), and the rest is thegroupId
where all/
need to be replaced with.
(e.g.com.load.runners
). Note that you'll need to do the aggregation of versions to artifacts on your own.