[英]How to write command line (in jenkins) using robocopy to zip one folder?
How to write command line (in jenkins) using robocopy to zip one folder? 如何使用robocopy编写命令行(使用jenkins)压缩一个文件夹? lets say older then 2 month.
假设年龄大于2个月。
I have jenkins running on windows server (vm), and installed 7zip. 我在Windows服务器(vm)上运行了jenkins,并安装了7zip。
I need to make jenkins run robocopy to archive some folders older then 2 months. 我需要让jenkins运行robocopy来存档一些早于2个月的文件夹。
First of all robocopy
is just for copying files. 首先,
robocopy
仅用于复制文件。 I am assuming you are using Linux Distribution. 我假设您正在使用Linux Distribution。
find . -mtime +60
find . -mtime +60
with this you can list all the files recursively including sub folders which are older than 2 months. find . -mtime +60
,您可以递归列出所有文件,包括2个月以上的子文件夹。 Or else you can use find . -type d -mtime +60 -maxdepth=1
否则您可以使用
find . -type d -mtime +60 -maxdepth=1
find . -type d -mtime +60 -maxdepth=1
to list all the directories only in the current directory. find . -type d -mtime +60 -maxdepth=1
以仅列出当前目录中的所有目录。 use -type f
for listing all the files. 使用
-type f
列出所有文件。
This will list all the files and prints on the console. 这将列出所有文件并在控制台上打印。
for i in `find . -type d -mtime +60 -maxdepth 1`; do echo $i; done
For you, this will do the trick. 对于您来说,这可以解决问题。
for i in `find . -type d -mtime +60 -maxdepth 1`; do zip -r $i.zip $i; done
In the job config, Have a build step Execute Shell
and copy the code and zip folders will be there. 在作业配置中,
Execute Shell
构建步骤Execute Shell
并复制代码和zip文件夹。 Hope this helps. 希望这可以帮助。 If any doubts, Please comment.
如有任何疑问,请发表评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.