简体   繁体   English

Ant / ivy脚本帮助删除具有阈值的旧工件

[英]Ant/ivy script help to remove old artifacts with threshold

I'm really new to Apache Ant,ivy & artifactory. 我真的对Apache Ant,ivy和人工制品很陌生。 I just have a requirement which someone can help me figuring out how to proceed or the XML code if possible. 我只是有一个要求,有人可以帮助我弄清楚如何进行操作,或者尽可能地提供XML代码。

Suppose I have 3 artifacts present in artifactory.. Eg. 假设我在人工制品中存在3个人工制品。 Threshold is 3.. When I'm running the new build, my ant/ivy script should detect that there are 3 files already in artifactory, It should remove the oldest file and then upload the latest build package into artifactory.. This is avoid too many files in artifactory and clean it up easily. 阈值为3。运行新版本时,我的ant / ivy脚本应检测到工件中已有3个文件,应删除最旧的文件,然后将最新的构建包上传到工件中。工件中的文件过多,很容易清理。 We need a standard code put into every Ant script so that the artifactory is clean.. 我们需要在每个Ant脚本中放入标准代码,以确保工件干净。

If you are referring to Snapshot artifacts than Artifactory has a built in mechanism for limiting the number of snapshots. 如果您指的是快照工件,那么Artifactory具有内置机制来限制快照数量。
To specify the maximum number of snapshots that may be stored, in the Edit Repository dialog, select the Basic Settings tab. 要指定可以存储的最大快照数量,请在“ 编辑存储库”对话框中,选择“ 基本设置”选项卡。
You first need to check the Handle Snapshots checkbox which then enables you to set the Max Unique Snapshots field. 您首先需要选中“处理快照”复选框,然后使您可以设置“ 最大唯一快照”字段。 This value is zero by default, which means that all snapshots are saved. 默认情况下,此值为零,这意味着将保存所有快照。

In addition you can cleanup artifacts by developing a custom user plugin or create an external script using the Artifactory REST API. 此外,您可以通过开发自定义用户插件来清除工件,也可以使用Artifactory REST API创建外部脚本。
Artifactory supports cleanup by allowing you to write custom User Plugins which you can develop to meet your own specific cleanup requirements. Artifactory通过允许您编写自定义用户插件来支持清理,您可以开发这些插件来满足自己的特定清理要求。 There are a number of cleanup scripts on GitHub which you can use as provided or modify to suit your own needs. GitHub上有许多清理脚本,您可以根据需要使用它们或对其进行修改以适合自己的需求。 Please not that user plugins is a feature of the Artifactory pro version. 请注意,用户插件是Artifactory专业版的功能。
Using the Artifactory REST API , you may write scripts to implement virtually any custom cleanup logic. 使用Artifactory REST API ,您可以编写脚本来实现几乎任何自定义清除逻辑。 You can use the various search APIs for finding artifacts you want to delete and use the delete item API for deleting them. 您可以使用各种搜索 API查找要删除的工件,并使用delete item API删除它们。

For more information and examples you can take a look at Managing Disk Space Usage 有关更多信息和示例,请查看管理磁盘空间使用情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM