Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TestAuto
InterfaceAutoTest
Commits
972edc28
Commit
972edc28
authored
Jun 01, 2021
by
taoke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化钉钉发送群消息方法
parent
1ae78899
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
38 deletions
+44
-38
common/utils/dingTalk.py
+36
-32
config.py
+6
-0
run.py
+2
-6
No files found.
common/utils/dingTalk.py
View file @
972edc28
...
...
@@ -41,12 +41,29 @@ def dingTalk_link(secret,webhook,message):
response
=
requests
.
post
(
webhook
,
headers
=
BaseConfig
.
headers
,
data
=
post_data
)
return
response
.
text
def
dingTalk_markdown
(
secret
,
webhook
,
message
):
# def dingTalk_markdown(secret,webhook,message):
# """发送消息到钉钉群"""
# timestamp = str(round(time.time() * 1000))
# sign=get_sign(secret)
# webhook=webhook+f"×tamp={timestamp}&sign={sign}"
# now_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
# data = {'msgtype': 'markdown',
# "markdown": {
# "title":"接口执行报告",
# "text": f"#### 接口自动化测试报告 \n> 本消息由Jenkins构建后自动发送\n> \
# \n> ###### 点击查看 >> [斑马信用](http://10.197.236.10:8080/job/bmc/allure/) \n"
# },
# 'at': {'isAtAll': False}}
# post_data = json.dumps(data)
# response = requests.post(webhook, headers=BaseConfig.headers, data=post_data)
# return response.text
def
dingTalk_markdown2
(
group
):
for
i
in
group
:
"""发送消息到钉钉群"""
timestamp
=
str
(
round
(
time
.
time
()
*
1000
))
sign
=
get_sign
(
secret
)
webhook
=
webhook
+
f
"×tamp={timestamp}&sign={sign}"
sign
=
get_sign
(
i
[
"secret"
]
)
webhook
=
i
[
"webhook"
]
+
f
"×tamp={timestamp}&sign={sign}"
now_time
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
)
data
=
{
'msgtype'
:
'markdown'
,
"markdown"
:
{
...
...
@@ -56,34 +73,21 @@ def dingTalk_markdown(secret,webhook,message):
},
'at'
:
{
'isAtAll'
:
False
}}
post_data
=
json
.
dumps
(
data
)
response
=
requests
.
post
(
webhook
,
headers
=
BaseConfig
.
headers
,
data
=
post_data
)
return
response
.
text
requests
.
post
(
webhook
,
headers
=
BaseConfig
.
headers
,
data
=
post_data
)
if
__name__
==
'__main__'
:
# res=dingTalk_markdown(secret = "SEC465015385218e70a94f107a16f72dd33d8fc118c3b2a631e0433685302f2fbb3",
# webhook = "https://oapi.dingtalk.com/robot/send?access_token=229908a83825ed56abbf728d3382e446a4e8a90e9ad302c37a036bcbccbbf9ee",
# message="小组")
# print(res)
# now_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
# print(now_time)
res
=
dingTalk_markdown
(
secret
=
"SEC40a1be4bbd9214e16ba288208fd608b2b590e82e853fa9b24c1850a506c6185b"
,
webhook
=
"https://oapi.dingtalk.com/robot/send?access_token=e830b05eeee88da31972099e403a74d05ec55719360707dc44e532c0d0b49cb6"
,
message
=
"小帅"
)
print
(
res
)
# 自动化测试组 - 技术和思路分享 - ----小帅
# secret = "SEC40a1be4bbd9214e16ba288208fd608b2b590e82e853fa9b24c1850a506c6185b",
# webhook = "https://oapi.dingtalk.com/robot/send?access_token=e830b05eeee88da31972099e403a74d05ec55719360707dc44e532c0d0b49cb6",
# 自动化小组
# secret = "SEC465015385218e70a94f107a16f72dd33d8fc118c3b2a631e0433685302f2fbb3",
# webhook = "https://oapi.dingtalk.com/robot/send?access_token=229908a83825ed56abbf728d3382e446a4e8a90e9ad302c37a036bcbccbbf9ee"
# # 斑马信用测试
# secret = "SECd10e7eaf4ae5e4a9b15cb059951519c0d8537721fd588e38b861c411ce6442d3"
# webhook= "https://oapi.dingtalk.com/robot/send?access_token=9755709d67e98f6adfa09c884b2b62480b5315ffb65acde5309094206374e3a1"
\ No newline at end of file
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"
:
"自动群"
}]
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
config.py
View file @
972edc28
...
...
@@ -15,6 +15,12 @@ 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"
:
"自动化小组"
}]
# 日志相关
log_path
=
r''
# 日志路径
...
...
run.py
View file @
972edc28
...
...
@@ -29,11 +29,7 @@ if __name__ == "__main__":
# os.system('allure serve ./report/tmp')
# 发送钉钉 ()
dingTalk
.
dingTalk_markdown
(
secret
=
"SEC465015385218e70a94f107a16f72dd33d8fc118c3b2a631e0433685302f2fbb3"
,
webhook
=
"https://oapi.dingtalk.com/robot/send?access_token=229908a83825ed56abbf728d3382e446a4e8a90e9ad302c37a036bcbccbbf9ee"
,
message
=
"自动化测试小组"
)
dingTalk
.
dingTalk_markdown2
(
BaseConfig
.
bmc_group
)
dingTalk
.
dingTalk_markdown
(
secret
=
"SECd10e7eaf4ae5e4a9b15cb059951519c0d8537721fd588e38b861c411ce6442d3"
,
webhook
=
"https://oapi.dingtalk.com/robot/send?access_token=9755709d67e98f6adfa09c884b2b62480b5315ffb65acde5309094206374e3a1"
,
message
=
"斑马信用测试"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment