7zip需要永远提取

时间:2016-09-22 15:57:09

标签: jenkins 7zip

使用7zip压缩一组文件夹,如下所示:

 def list = ["dir1", "dir2", "dir3"]
                   for (int i = 0; i < list.size(); i++) {
                     def dir = list.get(i);
                       bat "7z a %cd%\\artifacts\\${dir}.zip %cd%\\src\\${dir}\\obj\\*"
                       }

然后将拉链复制到共享驱动器并使用以下命令远程提取它们:

def list_a = ["dir1", "dir2", "dir3"]
                for (int i = 0; i < list_a.size(); i++) {
                def dir = list_a.get(i);
                    bat "copy %cd%\\artifacts\\${dir}.zip  \\\\shared_drive\"
                    bat "7z x \\\\shared_drive\\\${dir}.zip -o\\\\shared_drive\\\${dir} -y"   //This step with extraction, takes a very long time for folders with a lot of files in it ( as compared using the GUI (right click and extract on the folder)
                    bat "del /Q \\\\shared_drive\\\${dir}.zip"
                }

我在提取时保留文件夹结构。

有没有办法可以将提取过程固定到使用鼠标图形界面时获得的速度?

1 个答案:

答案 0 :(得分:0)

我不希望CLI和GUI之间存在差异。但是,您的设置中存在一个常见的陷阱:从网络中提取存档到同一个网络驱动器可能会非常慢

最好完全避免将存档复制到共享的中间步骤。如果%cd%是您设置中的本地驱动器,则会执行以下操作:

def list_a = ["dir1", "dir2", "dir3"]
                for (int i = 0; i < list_a.size(); i++) {
                def dir = list_a.get(i);
                    bat "7z x %cd%\\artifacts\\${dir}.zip -o\\\\shared_drive\\\${dir} -y"   //This step with extraction, takes a very long time for folders with a lot of files in it ( as compared using the GUI (right click and extract on the folder)
                }

否则,首先可能需要将存档复制到本地驱动器,然后将其解压缩。