You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.7 KiB

1 month ago
# encoding: utf-8
import task
import tools
import sys
import os
from pathlib import Path
class CIProcess():
def __init__(self, local_name, upload_path, upload_name_prex, build_version, build_number, p4path, notice_webhook, suffix):
self.local_name = local_name
self.upload_path = upload_path
self.upload_name_prex = upload_name_prex
self.build_version = build_version
self.build_number = build_number
self.p4path = p4path
self.notice_webhook = notice_webhook
self.suffix = suffix
# 通知上传下载
def NoticeUpload(self, upload_name, p4number, p4author):
upload_full_path = self.upload_path + "/" + upload_name
job_name = os.getenv('JOB_NAME')
content="<font color=#8B008B>{}</font> 成功! p4:{} 提交者:@<font color=#8B008B>{}</font> [点击下载安装包!]({})"\
.format(job_name, p4number, p4author, upload_full_path)
tools.SendRobot(self.notice_webhook, content)
print(upload_full_path)
sys.stdout.flush()
def Run(self):
if False == Path(self.local_name).is_file():
print("self.local_name is not exist, %s" % self.local_name)
return -1
now = tools.GetTime()
p4_number, p4_author = tools.GetP4Info(self.p4path)
upload_name = upload_name_prex + "_" + self.build_version + "_" + self.build_number + "_" + now + "_" + "p4:" + p4_number + "_" + p4_author + "." + self.suffix
tools.UploadNexus(self.upload_path, self.local_name, upload_name)
self.NoticeUpload(upload_name, p4_number, p4_author)
return 0
if __name__ == '__main__':
if (9 > len(sys.argv)):
print("ERROR: args not enoug!")
os._exit(-1)
local_name = sys.argv[1]
upload_path = sys.argv[2]
upload_name_prex = sys.argv[3]
build_version = sys.argv[4]
build_number = sys.argv[5]
p4path = sys.argv[6]
notice_webhook = sys.argv[7]
suffix = sys.argv[8]
print("local_name %s" % local_name )
print("upload_path %s" % upload_path )
print("upload_name_prex %s" % upload_name_prex)
print("build_version %s" % build_version )
print("build_number %s" % build_number )
print("p4path %s" % p4path )
print("notice_webhook %s" % notice_webhook )
process = CIProcess(local_name, upload_path, upload_name_prex, build_version, build_number, p4path, notice_webhook, suffix)
# ret = task.Start(15, process)
ret = process.Run()
print("ret:%d" % ret)
os._exit(ret)