【问题标题】:list all artifacts in a repository on JFrog Artifactory列出 JFrog Artifactory 上存储库中的所有工件
【发布时间】:2016-03-31 22:42:07
【问题描述】:

我是 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 数据库和 http 请求中获取 repos 列表)。

尝试匿名列出使用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 中的工件列表。谢谢!

【问题讨论】:

  • 如果您提供 AQL 内联并获得不受支持的媒体异常,您可以通过添加 -H "Content-Type: text/plain" 来解决该问题。

标签: curl artifactory


【解决方案1】:

AQL 是要走的路。而且您的查询几乎很好(您忘记了所有以warweb 开头的存储库的$match。问题是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)"

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

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

【讨论】:

  • 嗨@JBaruch。我已经尝试过你的建议,但没有运气。工件本身似乎存在问题。
  • 嗨@JBaruch。我已经尝试过你的建议,但没有运气。它看起来像工件本身的一些问题。我已经用 -k 更新了 curl 命令(添加以跳过证书验证)。我猜它无法达到神器。 $curl -u pkjogi:Ilikemyself@123 -X POST -k artifactory.clearslideng.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)"
  • 让我们做一些简单的事情。从 curl 执行 a system ping request。如果失败,请使用带有-vv 标志的 curl 输出提出一个新问题。
  • 能够连接到服务器,但它看起来像 AQL 的问题。连接到 artifactory.xxx.com (127.0.0.1) 端口 443 (#0) ................... ..................... GET /artifactory/api/search/aql HTTP/1.1 > 授权:基本 sdifjdsmclkxzmsqwdspxzzfjla== > 用户代理:curl/7.40.0 >主机:artifactory.xxxx.com > 接受:/ >
  • 嗨!自从被问到这个问题已经很久了,但是:如果我使用给定的调用,我会收到“不支持的媒体类型”错误。有什么想法吗?
【解决方案2】:

对我来说,当我使用 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

【讨论】:

    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-06-05
      • 2018-09-28
      • 1970-01-01
      • 1970-01-01
      • 2016-07-18
      • 2013-04-25
      • 1970-01-01
      • 2016-09-03
      • 1970-01-01
      相关资源
      最近更新 更多