列出JFrog Artifactory上的存储库中的所有工件

时间:2016-03-31 22:42:07

标签: curl artifactory

我是Artifactory的新手。目前我正在开发一个项目来列出存储库中的所有工件。

Artifactory版本:4.1.3 Pro(关闭证书验证)

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>

抛出错误(错误请求)。尝试列出以下repos war,war-dev,war-release,webapp,webapp-dev中的工件(从Artifactory数据库获取repos列表和http请求)。

试图匿名列出使用REST调用的工件,但$ARTIFACTORY_HOME/logs/request_trace.log $ARTIFACTORY_HOME/logs/request.log

中没有日志

从artdb(Artifactory数据库)和artifactory url获取repos列表。列出的回购不同于一个。哪一个是正确的?

列出了这么多的回购

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

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

有人可以帮助找出repo中的工件列表。谢谢!

3 个答案:

答案 0 :(得分:14)

AQL是要走的路。您的查询几乎好(您忘记$match所有以warweb开头的回购。问题是卷曲。如果您想写您需要在命令行中查询所有内部"$的查询字符串。这是工作查询:

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)"

现在,这是地狱。相反,请考虑在文本文件中编写查询并将其与-d @filename.aql一起传递。在这种情况下,您不需要所有转义,查询将如下所示:

items.find({
  "type" : "file",
  "$or":[{
    "repo" : {"$match" : "war*"}, 
    "repo" : {"$match" : "web*"} }]})
  .include("name","repo","path","size")
  .sort({"$desc": ["size"]})
  .limit(10)

答案 1 :(得分:1)

这对我也有用。你可以编写@JBaruch指定的命令,也可以运行json AQL文件。

$ curl -u uname -X POST http://host:8081/artifactory/api/search/aql -H&#34; content-type:application / json&#34; -d @ filename.aql

答案 2 :(得分:0)

对我来说,当我使用Content-Type文本/纯文本而不是application / json时,它起作用了

curl -u uname -X POST http://host:8081/artifactory/api/search/aql -H "content-type: text/plain" -d @filename.aql