Commit 96e6d581 by taoke

钉钉群根据项目名称发送

parent 1ed9d867
......@@ -4,6 +4,7 @@ import json
import logging
import requests,allure
from config import *
from common.utils.dingTalk import dingTalk_markdown2,dingTalk_markdown_bmy
def request_main(url, headers, method, data, has_token=False):
......@@ -83,9 +84,15 @@ def get_case_dir(product_name):
return test_case_dir
def get_send_dingding(product_name):
def send_dingding(product_name):
"""根据传入的产品名来 发送对应的钉钉群"""
pass
if product_name == BMCConfig.name:
dingTalk_markdown2(BaseConfig.bmc_group) # 给斑马信用相关群发送钉钉
if product_name == BmyConfig.name:
dingTalk_markdown_bmy(BaseConfig.bmy_group) # 给交委项目相关群发送钉钉
if product_name == SSOConfig.name:
pass
def get_run(envrioment):
......
......@@ -60,7 +60,7 @@ def dingTalk_link(secret,webhook,message):
def dingTalk_markdown2(group):
for i in group:
"""发送消息到钉钉群"""
"""发送消息到钉钉群(斑马信用)"""
timestamp = str(round(time.time() * 1000))
sign=get_sign(i["secret"])
webhook=i["webhook"]+f"&timestamp={timestamp}&sign={sign}"
......@@ -75,19 +75,40 @@ def dingTalk_markdown2(group):
post_data = json.dumps(data)
requests.post(webhook, headers=BaseConfig.headers, data=post_data)
def dingTalk_markdown_bmy(group):
for i in group:
"""发送消息到钉钉群(交委)"""
timestamp = str(round(time.time() * 1000))
sign=get_sign(i["secret"])
webhook=i["webhook"]+f"&timestamp={timestamp}&sign={sign}"
now_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
data = {'msgtype': 'markdown',
"markdown": {
"title":"接口执行报告",
"text": f"#### 接口自动化测试报告 \n> 本消息由Jenkins构建后自动发送\n> \
![screenshot](https://aqjg.gyszhjt.com:60028/img/group1/M00/00/04/Cgs5XWD2NrOACeeHAAhEU1jS9Xc475.png)\n> ###### 点击查看 >> [安全运输](http://10.197.236.10:8080/job/bmy/allure/) \n"
},
'at': {'isAtAll': False}}
post_data = json.dumps(data)
requests.post(webhook, headers=BaseConfig.headers, data=post_data)
if __name__ == '__main__':
test_group =[{"secret":"SEC40a1be4bbd9214e16ba288208fd608b2b590e82e853fa9b24c1850a506c6185b",
"webhook":"https://oapi.dingtalk.com/robot/send?access_token=e830b05eeee88da31972099e403a74d05ec55719360707dc44e532c0d0b49cb6",
"group":"自动化测试组 - 技术和思路分享"},
{"secret": "SEC1d08f46da74337cc0e1cd5bb9ad19622d825483343fdfa43ce396881e4745bdb",
"webhook": "https://oapi.dingtalk.com/robot/send?access_token=f9e005c1a984b9607960345d38669337b1115d1141a0294e98666443b312115b",
"group": "自动群"}]
"group":"自动化测试组 - 技术和思路分享"}
# ,
# {"secret": "SEC1d08f46da74337cc0e1cd5bb9ad19622d825483343fdfa43ce396881e4745bdb",
# "webhook": "https://oapi.dingtalk.com/robot/send?access_token=f9e005c1a984b9607960345d38669337b1115d1141a0294e98666443b312115b",
# "group": "自动群"}
]
bmc_group= [{"secret":"SECd10e7eaf4ae5e4a9b15cb059951519c0d8537721fd588e38b861c411ce6442d3",
"webhook":"https://oapi.dingtalk.com/robot/send?access_token=9755709d67e98f6adfa09c884b2b62480b5315ffb65acde5309094206374e3a1",
"group":"斑马信用测试"},
{"secret": "SEC465015385218e70a94f107a16f72dd33d8fc118c3b2a631e0433685302f2fbb3",
"webhook": "https://oapi.dingtalk.com/robot/send?access_token=229908a83825ed56abbf728d3382e446a4e8a90e9ad302c37a036bcbccbbf9ee",
"group": "自动化小组"}]
dingTalk_markdown2(bmc_group)
\ No newline at end of file
dingTalk_markdown_bmy(test_group)
\ No newline at end of file
......@@ -15,12 +15,17 @@ class BaseConfig():
# 钉钉相关
webhook = ''
# 斑马信用钉钉群
bmc_group = [{"secret": "SECd10e7eaf4ae5e4a9b15cb059951519c0d8537721fd588e38b861c411ce6442d3",
"webhook": "https://oapi.dingtalk.com/robot/send?access_token=9755709d67e98f6adfa09c884b2b62480b5315ffb65acde5309094206374e3a1",
"group": "斑马信用测试"},
{"secret": "SEC465015385218e70a94f107a16f72dd33d8fc118c3b2a631e0433685302f2fbb3",
"webhook": "https://oapi.dingtalk.com/robot/send?access_token=229908a83825ed56abbf728d3382e446a4e8a90e9ad302c37a036bcbccbbf9ee",
"group": "自动化小组"}]
# 交委钉钉群
bmy_group =[{"secret":"SEC40a1be4bbd9214e16ba288208fd608b2b590e82e853fa9b24c1850a506c6185b",
"webhook":"https://oapi.dingtalk.com/robot/send?access_token=e830b05eeee88da31972099e403a74d05ec55719360707dc44e532c0d0b49cb6",
"group":"自动化测试组 - 技术和思路分享"}]
# 日志相关
log_path = r'' # 日志路径
......
......@@ -3,7 +3,7 @@ import os
import pytest
import argparse
from config import BaseConfig
from common.tools import get_case_dir
from common.tools import get_case_dir,send_dingding
from common.utils import dingTalk
......@@ -26,10 +26,10 @@ if __name__ == "__main__":
# 生成报告数据
pytest.main(['-v', '-s', test_case_dir, '--alluredir', './report/tmp'])
# 打开报告
# os.system('allure serve ./report/tmp')
# 发送钉钉 ()
dingTalk.dingTalk_markdown2(BaseConfig.bmc_group)
os.system('allure serve ./report/tmp')
# 发送钉钉
send_dingding(args.product)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment