Jfrog Cli保留n最新文物其他删除

发布于 2025-02-12 15:06:28 字数 535 浏览 0 评论 0原文

我正在与JFROG CLI合作,需要在存储库中清理文件夹中的工件,并且仅保留5个最新文物(最新的日期)。

我已经创建了一些代码,这些代码删除了创建了7天和更多天的工件。但是我需要保留5个最新工件。有人有什么想法吗?

{
  "files": [
    {
      "aql": {
        "items.find": {
          "repo": "maven-repo",
          "path": {"$match":"com/mqjbnd64/7.1"},
          "name": {"$match":"*"},
          "$or": [
            {
              "$and": [
                {
                  "created": { "$before":"7d" }
                }
              ]
            }
          ]
        }
      }
    }
  ]
} 

I'm working with JFROG Cli and need to cleanup artifacts from folder under repository and keep only 5 latest artifacts (latest by created date).

I have already created some code which removes artifacts which were created 7 and more days. But I need to keep 5 latest artifacts. Anyone has any ideas?

{
  "files": [
    {
      "aql": {
        "items.find": {
          "repo": "maven-repo",
          "path": {"$match":"com/mqjbnd64/7.1"},
          "name": {"$match":"*"},
          "$or": [
            {
              "$and": [
                {
                  "created": { "$before":"7d" }
                }
              ]
            }
          ]
        }
      }
    }
  ]
} 

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

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

发布评论

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

评论(2

梦里寻她 2025-02-19 15:06:28

您可以通过创建日期来创建初始查询排序,并将返回的记录数限制为5。
比您可以执行另一个查询,以在此路径中获取所有工件,并删除了上一个查询未返回的伪像。

You can create an initial query sorting by create date and limiting the number of records returned to 5.
Than you can execute another query, to get all artifacts in this path, and deleted the ones not returned by the previous query.

别把无礼当个性 2025-02-19 15:06:28

我通过使用以下文件规格来使此功能工作:

{
    "$schema": "https://github.com/jfrog/jfrog-cli/blob/v2/schema/filespec-schema.json",

    "files":
    [
        {
            "aql":
            {
                "items.find":
                {
                    "repo": "maven-repo",
                    "path": "com/mqjbnd64/7.1",
                    "name": { "$match": "*" },
                    "created": { "$before": "7d" }
                }
            },
            "sortBy": [ "created" ],
            "sortOrder": "desc",
            "offSet": 5
        }
    ]
}

基本上它的作用是对过去7天之前创建的所有工件的首次查询。然后,它按创建日期对此列表进行排序,并通过Offset删除了前5个结果。

编辑:这实际上并不能完全正如我希望的那样工作,因为它仅过滤超过7D的软件包,因此,如果有X封装比7D更新,它将保留X + 5个软件包。但这是一个开始。

I got this to work by using the following file spec:

{
    "$schema": "https://github.com/jfrog/jfrog-cli/blob/v2/schema/filespec-schema.json",

    "files":
    [
        {
            "aql":
            {
                "items.find":
                {
                    "repo": "maven-repo",
                    "path": "com/mqjbnd64/7.1",
                    "name": { "$match": "*" },
                    "created": { "$before": "7d" }
                }
            },
            "sortBy": [ "created" ],
            "sortOrder": "desc",
            "offSet": 5
        }
    ]
}

Basically what it does is first query for all artifacts created before the last 7 days. It then sorts this list by creation date and removed the first 5 results via the offSet.

Edit: this does not actually work entirely as I hoped since it only filters the packages that are older than 7d, so if there are X packages newer than 7d, it will keep X + 5 packages. But it is a start.

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