【问题标题】:Artifactory old artifacts clean up (CLI + AQL)Artifactory 旧工件清理 (CLI + AQL)
【发布时间】:2020-04-01 20:43:06
【问题描述】:

我正在努力寻找使用 AQL 和 CLI 从 Artifactory 清理所有 RPM 存储库的解决方案。例如,我想删除过去 12 个月内未下载的所有内容(如果创建日期早于 1 年并且从未下载过)。我认为最难的部分是我还需要在每个存储库中保留最后 x 个 RPM 文件(例如最后下载的最后 3 个 rpm 文件)。知道如何执行此任务或是否有可能,尤其是保留最后下载的部分。任何建议表示赞赏。

谢谢, 丹尼

【问题讨论】:

    标签: artifactory jfrog-cli artifactory-query-lang


    【解决方案1】:

    使用 jfrog CLI 和 AQL 清理旧工件

    JFrog CLI 是一个紧凑而智能的客户端,它提供了一个简单的界面来自动访问 Artifactory。作为 REST API 的包装器。

    安装 JFrog CLI

    在 MAC 上

    brew install jfrog-cli-go
    

    带卷曲

    curl -fL https://getcli.jfrog.io | sh
    

    JFrog CLI 语法

    jfrog target command-name global-options command-options arguments
    

    目标 - 您希望对其执行命令的产品:

    rt: JFrog Artifactory
    bt: JFrog Bintray
    mc: JFrog Mission Control
    xr: JFrog Xray
    

    配置 JFrog cli

    jfrog rt c Artifactory --url=https://artifactory.eqs.intra/artifactory --apikey=<add api key> #can generate api key from user profile
    

    生成 API 密钥

    登录到 artifactory -> 点击用户名并编辑配置文件 -> 在身份验证设置下

    JFrog CLI configuration Official Documentation

    搜索文物

    显示来自的工件 - 注册表 - docker - 路径 - * - 下载状态=null#未下载 - 在1 month之前创建

    {
      "files": [
        {
          "aql": {
            "items.find": {
              "repo": {"$eq":"docker"},
              "path": {"$match":"*"},
              "name": {"$match":"*"},
              "stat.downloads":{"$eq":null},
              "$or": [
                {
                  "$and": [
                    {
                      "created": { "$before":"1mo" }
                    }
                  ]
                }
              ]
            }
          }
        }
      ]
    }
    

    AQL Official Documentation.

    运行搜索并验证您要删除的包

    jfrog rt s --spec artifactory.spec 
    

    按照规范文件删除工件

    jfrog rt del --spec artifactory.spec
    

    Insight Page

    【讨论】:

      猜你喜欢
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多