标签:use payload desc shel account 用户 sel python date
Jenkins运行成功后,需要发送消息给用户,自己封装了一个rtx的方法,进行发送,配置方法如下:
1.在windows下选择 execute windows batch command,执行我的python文件,
注意,在liunx系统中要使用 execute shell
自定义的消息内容为:
我的消息内容读取的是生成文件的html,
代码如下:
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: User # @Date : 2019/3/15 10:42 # @Desc : Description import requests,json from bs4 import BeautifulSoup class message: def __init__(self,url): self.url=url def MyHTMLParser(self): executeStae= "成功" result = [] #打开文件 soup = BeautifulSoup(open(self.url)) #获取执行时间 runTime = soup.td.string # 过滤主要的数据 htmlContnet=soup.find_all(align=‘center‘,limit=1) print(htmlContnet) #单个同级的目录的数据 sumNumber=htmlContnet[0].td.next_sibling.string #同级目录的数据 for siblings in htmlContnet[0].td.next_siblings: sigle=siblings.string print(siblings) result.append(sigle) faileNmuber=result[0] successNmuber=int(sumNumber)-int(result[0]) if faileNmuber!=0: executeStae="失败" content = ‘运行信息:\r\n总接口数:‘ + str(sumNumber) + ‘, 通过:‘ + str(successNmuber) + ‘, 未通过:‘ + str(faileNmuber) + ‘\r\n运行结果:‘ + executeStae + ‘\r\n运行时间:‘ + runTime return content def sendsRtx(self,contnet): url = ‘http://msgcenter100.com/api-source/index‘ payload = { "account": "xx", "password": "xx", "api_key": "xx", "data": [ { "content": xx, "title": "TEST", "to": "xx", "channel": "rtx" } ] } res = requests.post(url, data=json.dumps(payload)) print(res.text) if __name__==‘__main__‘: m=message(‘D:/jmeterDemo/demo/report/html/23$.html‘) transForm=m.MyHTMLParser() m.sendsRtx(transForm)
标签:use payload desc shel account 用户 sel python date
原文地址:https://www.cnblogs.com/chongyou/p/10551341.html