我是靠谱客的博主 开朗蓝天,这篇文章主要介绍遍历jenkins build后的文件夹,找出最新“build NO.”复制到制定目录进行操作,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding: utf-8 -*- import os import shutil import sys def UnZipFile(inputPath, outPath): _unZipPath = os.getcwd() + "\7-Zip\7z.exe "#原来输出成果物的进行了压缩,输出到指定的build里,所以我们要利用7z.exe来解压缩。需要调用此程序 _param = " x " + inputPath + " -o" _param = _param + outPath _cmd = _unZipPath + _param print _cmd os.system(_cmd) def GetbiggestFolder(inputPath): #获取文件夹操作 _maxPath = "" _maxNum = 0 for folder in os.listdir(inputPath): _inputFolderPath = os.path.join(inputPath, folder) if os.path.isdir(_inputFolderPath): if str(folder).isdigit(): if int(folder) > _maxNum : _maxNum = int(folder) _maxPath = _inputFolderPath return _maxPath def copyFile(_oldPath, _newPath): if os.path.exists(_newPath) is not True: os.makedirs(_newPath) if os.path.isdir(_newPath): shutil.copy(_oldPath, _newPath) def Usage(s = ""): print "Usage: unzip.py [source folder] [target folder]" if s: print s sys.exit(1) if __name__ == "__main__": """while True: g_InputPath = raw_input("Please input source folder path:") if g_InputPath.rfind('\') != -1: break while True: g_OutputPath = raw_input("Please input target folder path:") if g_OutputPath.rfind('\') != -1: break """ argv = sys.argv i = 1 iLen = len(argv) if len(argv) != 3: _errorInfor = "There should be 2 parameters, but you input " + str(iLen -1) Usage(_errorInfor) g_InputPath = argv[1] g_OutputPath = argv[2] _maxPath = GetbiggestFolder(g_InputPath) print _maxPath for _file in os.listdir(_maxPath): _inputFilePath = os.path.join(_maxPath, _file) if os.path.isfile(_inputFilePath): if _file.find('.7z') != -1 or _file.find('.rar') != -1 or _file.find('.zip') != -1: print _inputFilePath UnZipFile(_inputFilePath, g_OutputPath) copyFile(_inputFilePath, g_OutputPath)

 

转载于:https://www.cnblogs.com/BUGU/p/5381933.html

最后

以上就是开朗蓝天最近收集整理的关于遍历jenkins build后的文件夹,找出最新“build NO.”复制到制定目录进行操作的全部内容,更多相关遍历jenkins内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部