人工工厂删除所有6个月以上的人工制品 [英] Artifactory delete all artifacts older than 6 months

查看:79
本文介绍了人工工厂删除所有6个月以上的人工制品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何从人为因素中删除所有与某个模式(例如,大于6个月大)相匹配的人为因素?

How would you delete all artifacts that match a pattern (e.g older than 6 months old) from artifactory?

使用curl或go库

推荐答案

jfrog cli使用规范文件"搜索工件.有关有关jfrog规范文件的信息,请参见此处

The jfrog cli takes a 'spec file' to search for artifacts. See here for information on jfrog spec files

jfrog cli 此处提供了文档:

The jfrog cli documentation is available here:

创建aql搜索查询以仅查找所需的工件:

Create an aql search query to find just the artifacts you want:

如果您的aql搜索语法类似于:

If your aql search syntax were like:

/tmp/foo.query

/tmp/foo.query

items.find(
  {
    "repo":"foobar",
    "modified" : { "$lt" : "2016-10-18T21:26:52.000Z" }
  }
)

您可以找到这样的工件:

curl -X POST -u admin:<api_key> https://artifactory.example.com/artifactory/api/search/aql -T foo.query

那么规格文件将是

/tmp/foo.spec

/tmp/foo.spec

{
  "files": [
    {
      "aql": {
        "items.find": {
          "repo": "foobar",
          "$or": [
            {
              "$and": [
                {
                  "modified": { "$lt": "2016-10-18T21:26:52.000Z"}
                }
              ]
            }
          ]
        }
      }
    }
  ]
}

您将像这样使用golang库:

And you would use the golang library like so:

jfrog rt del --spec /tmp/foo.spec --dry-run

您也可以做一个相对日期,而不是修改日期

Instead of modified, you can also do a relative date

"modified": { "$before":"6mo" }

如果收到错误405方法不允许,请确认您的api或密码正确无误,然后尝试使用PUT代替POST

If you get error 405 Method not allowed, verify you have an api or password correct, and try using PUT instead of POST

这篇关于人工工厂删除所有6个月以上的人工制品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆