从本地nexus存储库中删除超过2年的工件

问题描述 投票:12回答:5

我们在一些旧硬件上运行nexus,这些硬件在磁盘空间方面有限,并且想要移除早于某个阈值的工件。

除了find和curl的组合之外,还有什么方法可以做到这一点吗?

nexus
5个回答
8
投票

有一个可以自动删除旧快照版本的计划任务:

不幸的是,这不适用于托管版本存储库。


5
投票

正如在Gavenkoa的回答博客评论中提到的Sonatype blog post linked所述,自Nexus 2.5以来,内置了“从存储库中删除发行版”计划任务,可以配置为删除保留定义数字的旧版本。

这足以满足我们的需求。


4
投票

删除所有无法访问100天以上且未修改超过200天的文件:

find . -type f -atime +100 -mtime 200 -delete

要清理空目录:

find . -type d -empty -delete

或者,请查看https://github.com/akquinet/nexus_cleaner/blob/master/nexus_clean.sh和相应的博客条目http://blog.akquinet.de/2013/12/09/how-to-clean-your-nexus-release-repositories/(删除除最近10个版本之外的所有内容)。


0
投票

自动清除超过30天(你可以更改它)不从nexus 3下载docker图像

https://gist.github.com/anjia0532/4a7fee95fd28d17f67412f48695bb6de

# nexus3's username and pwd
username = 'admin'
password = 'admin123'

# nexus host
nexusHost = 'http://localhost:8081'

# purge repo
repoName = 'docker'

# older than days
days = 30

#change and run it

0
投票

对于Nexus2,您可以使用我的Spring Boot应用程序https://github.com/vernetto/nexusclean,您可以根据日期和最少数量的Artifacts来定义规则以保留,并生成“rm -rf”命令(使用REST API非常慢)。

对于Nexus3,我肯定会使用Groovy脚本作为“执行管理任务”。一个是张贴在这里groovy script to delete artifacts on nexus 3 (not nexus 2)

© www.soinside.com 2019 - 2024. All rights reserved.