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

use*_*315 5 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>
Run Code Online (Sandbox Code Playgroud)

这是一个错误(错误的请求).尝试列出以下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/                                                    
Run Code Online (Sandbox Code Playgroud)

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

JBa*_*uch 14

AQL是要走的路.你的查询几乎是好的(你忘记了$match所有以waror 开头的repos web.问题是curl.如果你想在命令行中编写查询字符串,你需要逃避所有的内部"$.这是工作查询:

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)"
Run Code Online (Sandbox Code Playgroud)

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

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

  • 嗨!自从被问到这个问题已经很长时间了,但是:如果我按照给定的方式使用呼叫,我会收到"不支持的媒体类型"错误.任何的想法? (4认同)
  • @eventhorizo​​n您必须提供 Content-Type 标头,即 `-H "content-type: text/plain"` (4认同)

Rud*_*udi 5

对我来说,当我使用 Content-Type text/plain 而不是 application/json 时,它起作用了,即

curl -u uname -X POST http://host:8081/artifactory/api/search/aql -H "content-type: text/plain" -d @filename.aql
Run Code Online (Sandbox Code Playgroud)