简体   繁体   中英

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? lets say older then 2 month.

I have jenkins running on windows server (vm), and installed 7zip.

I need to make jenkins run robocopy to archive some folders older then 2 months.

First of all robocopy is just for copying files. I am assuming you are using 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. Or else you can use find . -type d -mtime +60 -maxdepth=1 find . -type d -mtime +60 -maxdepth=1 to list all the directories only in the current directory. use -type f for listing all the files.

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. Hope this helps. If any doubts, Please comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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