如何仅使用卷曲

发布于 2025-01-24 13:13:53 字数 1029 浏览 2 评论 0 原文

因此,我以前有一个脚本可以在我的文物存储库中搜索某个属性的文件夹。

curl -i -X GET "${ARTIFACTORY_URI}/api/search/prop?my-prop=aaa&repos=my-repo

到目前为止,一切都很好。我部署工件的方式是,我将它们放在子文件夹中,每个子文件夹都分配了属性myprop。然后,当我运行此命令时,我将获得了满足搜索条件的子文件夹的列表。之所以起作用,是因为子文件夹全部直接在存储库my-repo中。

但是,现在我们不得不对文物进行一些重组。现在,我要列出的子文件夹位于存储库内部的子文件夹中的一个子文件夹中。我的命令仍然有效,但它返回所有子文件夹。

例如,请考虑以下问题:

my-repo:
   * folder1
      + folder1-1
         - folder1-1-1 (my-prop=aaa)
         - folder1-1-2 (my-prop=bbb)
      + folder1-2
         - folder1-2-1 (my-prop=aaa)
   * folder2
      + folder2-1
         - folder2-1-1 (my-prop=aaa)

因此,使用同一命令搜索myprop = aaa时,我现在得到的是folder1-1-1,folder1-2-1和folder2-1-1。但是我想做的是将搜索限制为子扣式文件夹1-1。我尝试简单地将路径添加到 repos 参数,但它不起作用。

curl -i -X GET "${ARTIFACTORY_URI}/api/search/prop?my-prop=aaa&repos=my-repo/folder1/folder1-1

所以我的问题是如何做到这一点?伪像的网站是它的火车残骸,当然不是很有帮助。我可以使用其他文件夹/路径参数吗?我想指出的是,我正在研究一个非常限制的客户系统,并且无法访问Jfrog CLI工具,因此我必须使用Curl and Wget进行所有操作。

So I previously had a script to search for folders in my Artifactory repositories for a certain property.

curl -i -X GET "${ARTIFACTORY_URI}/api/search/prop?my-prop=aaa&repos=my-repo

So far so good. The way I deployed my artifacts was that I placed them in sub folders and each of the sub folders got assigned the property my-prop. Then when I ran this command, I got back a list of the sub folders that satisfied my search criteria. This worked because the sub folders where all directly inside the repo my-repo.

However now we have had to do some restructuring of the Artifactory. Now the sub folders that I'm trying to list are located in a sub folder inside a sub folder inside the repo. My command still works, but it returns all the sub folders.

For example consider this:

my-repo:
   * folder1
      + folder1-1
         - folder1-1-1 (my-prop=aaa)
         - folder1-1-2 (my-prop=bbb)
      + folder1-2
         - folder1-2-1 (my-prop=aaa)
   * folder2
      + folder2-1
         - folder2-1-1 (my-prop=aaa)

So what I get now when searching for my-prop=aaa using the same command is folder1-1-1, folder1-2-1 and folder2-1-1. But what I want to do is limit the search to the sub-sub-folder folder1-1. I tried to simply add the path to the repos parameter but it doesn't work.

curl -i -X GET "${ARTIFACTORY_URI}/api/search/prop?my-prop=aaa&repos=my-repo/folder1/folder1-1

So my question is how would one do that? The Artifactory website being the train wreck that it is, is of course not very helpful. Is there an additional folder/path parameter that I can use? I want to note, that I am working on an incredibly restrictive customer system and do not have access to the JFrog CLI tool, so I've got to do everything using curl and wget.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

节枝 2025-01-31 13:13:53

您应该能够使用为此。

在您的示例中,请使用类似的内容:

curl -X POST "${ARTIFACTORY_URI}/api/search/aql" \
     -H 'Content-Type: text/plain' \
     --data 'items.find({"repo":"my-repo","@my-prop":"aaa","path":"folder1","type":"folder"})'

这将在 my-repo 中进行文件夹带有给定属性的搜索,并在确切路径下进行搜索 。您可以使用其他运算符,例如 $ MATD ,如果路径应该是模式而不是确切的匹配。

有关完整的AQL语法和准则,请参见: >

You should be able to use AQL (Artifactory Query Language) for that.

For your example, use something like:

curl -X POST "${ARTIFACTORY_URI}/api/search/aql" \
     -H 'Content-Type: text/plain' \
     --data 'items.find({"repo":"my-repo","@my-prop":"aaa","path":"folder1","type":"folder"})'

This will do a search in my-repo for folders with the given property and under the exact path folder1. You can use other operators, like $match, if the path should be a pattern instead of an exact match.

For the full AQL syntax and guidelines, see: Artifactory Query Language

你是我的挚爱i 2025-01-31 13:13:53

与这个问题有些相关,我想我会在这里添加解决方案

,因此我试图

repoName
- folderA
  - folderA0
    - 0.0.1.zip
    - 0.0.2.zip
    ...
  - folderA1
    - 0.0.1.zip
    - 0.0.2.zip
    ...
- folderB
  - folderB1
    ...

通过此结构中的 curl 命令在此结构中是否存在伪像的伪像,我能够缩小到一个给定工件:

curl -u USERNAME:PASSWORD -X POST "${ARTIFACTORY_URI}/api/search/aql" -H 'Content-Type: text/plain' --data 'items.find({"repo":"repoName","path":"folderA/folderA0","name":"0.0.1.zip","type":"file"})'

我看起来像这样的输出,然后我可以用JSON Parser( jq ,编程语言库)对其进行解析

{
"results" : [ {
  "repo" : "repoName",
  "path" : "folderA/folderA0",
  "name" : "0.0.1.zip",
  "type" : "file",
  "size" : 75069478,
  "created" : "2022-10-24T17:22:10.260Z",
  "created_by" : "USER",
  "modified" : "2022-10-24T17:22:09.401Z",
  "modified_by" : "USER",
  "updated" : "2022-10-24T17:22:10.261Z"
} ],
"range" : {
  "start_pos" : 0,
  "end_pos" : 1,
  "total" : 1
}
}

{
"results" : [  ],
"range" : {
  "start_pos" : 0,
  "end_pos" : 0,
  "total" : 0
}
}

Somewhat related to this question and I thought I would add my solution here

So I was trying to query whether an artifact for a given version exists in this structure

repoName
- folderA
  - folderA0
    - 0.0.1.zip
    - 0.0.2.zip
    ...
  - folderA1
    - 0.0.1.zip
    - 0.0.2.zip
    ...
- folderB
  - folderB1
    ...

With this curl command I was able to narrow down to a given artifact:

curl -u USERNAME:PASSWORD -X POST "${ARTIFACTORY_URI}/api/search/aql" -H 'Content-Type: text/plain' --data 'items.find({"repo":"repoName","path":"folderA/folderA0","name":"0.0.1.zip","type":"file"})'

The output I got looked like this, which I can then parse with a JSON parser (jq, a programming language library)

{
"results" : [ {
  "repo" : "repoName",
  "path" : "folderA/folderA0",
  "name" : "0.0.1.zip",
  "type" : "file",
  "size" : 75069478,
  "created" : "2022-10-24T17:22:10.260Z",
  "created_by" : "USER",
  "modified" : "2022-10-24T17:22:09.401Z",
  "modified_by" : "USER",
  "updated" : "2022-10-24T17:22:10.261Z"
} ],
"range" : {
  "start_pos" : 0,
  "end_pos" : 1,
  "total" : 1
}
}

If the artifact did not exist, I got:

{
"results" : [  ],
"range" : {
  "start_pos" : 0,
  "end_pos" : 0,
  "total" : 0
}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文