Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list all artifacts in a repository on JFrog Artifactory

I'm new to the Artifactory. Currently I'm working on a project to list all the artifacts in a repository.

Artifactory version:4.1.3 Pro (turned off the cert verification)

curl -u uname:password -X POST -k https://artifactory.xxxx.com/artifactory/api/search/aql -d "items.find({"repo":"war"}).include("name","repo","path","size").sort({"$desc":["size"]}).limit(10)"


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /artifactory/api/search/aql was not found on this server.</p>
<hr>
<address>Apache/2.2.31 (Amazon) Server at artifactory.xxxx.com Port 443</address>
</body></html>

It's throwing an error(Bad request). Try to list out the artifacts in the following repos war,war-dev,war-release,webapp,webapp-dev(get the list of repos from Artifactory database and http request).

Tried to list out the artifacts using REST calls anonymously,But there are no logs in $ARTIFACTORY_HOME/logs/request_trace.log $ARTIFACTORY_HOME/logs/request.log

Get the list of repos from artdb(Artifactory database) and artifactory url. listed repos are different from one to other. Which one is correct?

Listed so many repos

mysql> select distinct(repo) from nodes;
| war                               |
| war-dev                           |
| war-release                       |

https://artifactory.xxxx.com/artifactory/repo/
webapp/                                                       
webapp-dev/                                                    

Can someone help to find out the list of artifacts in repo Please. Thank you!

like image 524
user6136315 Avatar asked Mar 31 '16 22:03

user6136315


People also ask

How do I find artifacts in Artifactory?

Using Quick Search you can search for artifacts by name. Select Quick Search, enter your search term and then click the "Search" button. The example below shows the results of searching for all artifacts whose name begins with "circle" in the "repo1-cache" repository.

How do I find my Artifactory repository?

Search in the browser: You can search for a specific repository in both browsers by clicking on the filter icon. Keyboard navigation: While in the browser, type the name of the repository you are searching for and Artifactory will navigate you to that repository.

What are artifacts in JFrog Artifactory?

A DevOps artifact is a by-product produced during the software development process. It may consist of the project source code, dependencies, binaries or resources, and could be represented in different layout depending on the technology.

How do I find my Artifactory repo size?

1, you can use the 'repoStats' user plugin. With this plugin, you can specify any path within a repository to get it's artifact count and size. If you need additional/altered, functionality in the plugin, you can edit it to adjust it to your own needs.


1 Answers

AQL is the way to go. And your query is almost good (you forgot the $match for all the repos starting with war or web. The problem is curl. If you want to write the query string in the command line you need to escape all the inner " and $. Here's the working query:

curl -u uname:password -X POST -k https://artifactory.xxxx.com/artifactory/api/search/aql -d "items.find({\"type\" : \"file\",\"\$or\":[{\"repo\" : {\"\$match\" : \"war*\"}, \"repo\" : {\"\$match\" : \"web*\"} }]}).include(\"name\",\"repo\",\"path\",\"size\").sort({\"\$desc\": [\"size\"]}).limit(10)"

Now, this is hell. Instead, consider writing the query in a text file and passing it with -d @filename.aql. In this case you don't need all the escaping and the query will look like:

items.find({
  "type" : "file",
  "$or":[{
    "repo" : {"$match" : "war*"}, 
    "repo" : {"$match" : "web*"} }]})
  .include("name","repo","path","size")
  .sort({"$desc": ["size"]})
  .limit(10)
like image 154
JBaruch Avatar answered Sep 29 '22 09:09

JBaruch