1、以管理员的身份 创建一个群,随意自定义命名,然后添加 群机器人
2、linux上安装python3
Centos镜像包地址:
http://isoredirect.centos.org/centos/7/isos/x86_64/
https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/isos/x86_64/
which python3
python3 --version
3. 在linux系统上运行Python脚本调试
import requests
import base64
import hashlib
import sys
import os
import subprocess
def wx_sendmessage():
(status,output) = subprocess.getstatusoutput("for i in `find /my_test2021/apache-jmeter-5.4.1/jmeter_test_report/html/TestStatisticsReport*.html -maxdepth 30 -type f|tail -n 1`;do basename $i; done")
str1=str(output)
print (str1)
status,output) = subprocess.getstatusoutput("for i in `find /my_test2021/apache-jmeter-5.4.1/jmeter_test_report/html/TestReportDetail*.html -maxdepth 30 -type f|tail -n 1`; do basename $i; done")
str2=str(output)
print (str2)
url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=这个值从上面获得"
headers = {"Content-Type": "application/json"}
data = {
"msgtype": "text",
"text": {
"content":"Jmter interface automation 接口测试汇总报告:http://172.16.110.199:8999/"+str1+ '\n\n'
+"Jmeter interface automation 接口测试详情报告:http://172.16.110.199:8999/"+str2+ '\n\n'
}
}
result = requests.post(url, headers=headers, json=data)
return result
if __name__ == '__main__' :
wx_sendmessage()
4、运行脚本查看效果
脚本命名为:wx_sendmessage.py
所在目录如下:
需要给python脚本加上权限, chmod 777 *
python3 wx_sendmessage.py
检查企业微信消息群 是否收到 发送的机器人消息。
运行这个脚本可以在jenkins上定时任务 自动执行。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。