# encoding: utf-8 import tools import sys import os from pathlib import Path class CIProcess(): def __init__(self, webhook, p4path, msg): self.webhook = webhook self.p4path = p4path self.msg = msg def Run(self): p4_number, p4_author = tools.GetP4Info(self.p4path) job_name = os.getenv('JOB_NAME') build_url = os.getenv('BUILD_URL') userid="<@" + p4_author + "@h3d.com.cn>" content = "{} {} p4提交号:{} 提交者:@{} [点击查看日志!]({}/consoleFull), 请处理{}".\ format(job_name, self.msg, p4_number, p4_author, build_url, userid) tools.SendRobot(self.webhook, content) return 0 if __name__ == '__main__': if (3 > len(sys.argv)): print("ERROR: args not enoug!") os._exit(-1) webhook = sys.argv[1] p4path = sys.argv[2] msg = sys.argv[3] print(webhook) print(p4path) print(msg) process = CIProcess(webhook, p4path, msg) ret = process.Run() print("ret:%d" % ret) os._exit(ret)