Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
willdesk_apiauto
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
29
Issues
29
List
Boards
Labels
Service Desk
Milestones
Merge Requests
29
Merge Requests
29
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
桦生 詹
willdesk_apiauto
Commits
19c095be
Commit
19c095be
authored
Apr 22, 2024
by
zhanhuasheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix
parent
54db255b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
Utils/webhook_handler.py
Utils/webhook_handler.py
+18
-2
No files found.
Utils/webhook_handler.py
View file @
19c095be
import
subprocess
import
requests
import
time
import
hmac
...
...
@@ -29,10 +31,11 @@ class webhookHandler:
"msgtype"
:
"markdown"
,
"markdown"
:
{
"title"
:
"#willdesk接口自动化测试报告"
,
"text"
:
"#### 本次接口自动化测试结果如下
\n
> ###### 用例总数:%s
\n
> ###### 成功用例数量:%s
\n
> ###### 失败用例数量:%s
\n
> ###### 报错用例数量:%s
\n
> ###### 跳过用例数量:%s
\n
> ###### 耗时:%s秒
\n
> ###### 报告生成时间:%s [测试报告](
https://www.baidu.com)"
%
(
result
.
_numcollected
,
len
(
result
.
stats
.
get
(
'passed'
,
[])),
len
(
result
.
stats
.
get
(
'failed'
,
[])),
len
(
result
.
stats
.
get
(
'error'
,
[])),
len
(
result
.
stats
.
get
(
'skipped'
,
[])),
second
,
current_date_time_str
)
"text"
:
"#### 本次接口自动化测试结果如下
\n
> ###### 用例总数:%s
\n
> ###### 成功用例数量:%s
\n
> ###### 失败用例数量:%s
\n
> ###### 报错用例数量:%s
\n
> ###### 跳过用例数量:%s
\n
> ###### 耗时:%s秒
\n
> ###### 报告生成时间:%s [测试报告](
%s)"
%
(
result
.
_numcollected
,
len
(
result
.
stats
.
get
(
'passed'
,
[])),
len
(
result
.
stats
.
get
(
'failed'
,
[])),
len
(
result
.
stats
.
get
(
'error'
,
[])),
len
(
result
.
stats
.
get
(
'skipped'
,
[])),
second
,
current_date_time_str
,
self
.
get_local_ip_address
()
)
},
}
res
=
requests
.
post
(
url
=
self
.
webhookUrl
,
json
=
data
)
# print(res.json())
def
sendMsg
(
self
,
title
,
text
):
...
...
@@ -45,5 +48,18 @@ class webhookHandler:
}
res
=
requests
.
post
(
url
=
self
.
webhookUrl
,
data
=
data
)
def
get_local_ip_address
(
self
):
cmd
=
'ifconfig'
result
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
text
=
True
,
shell
=
True
)
output
=
result
.
stdout
ip
=
None
for
line
in
output
.
split
(
'
\n
'
):
if
'inet '
in
line
and
'127.0.0.1'
not
in
line
:
ip
=
line
.
split
(
' '
)[
1
]
break
if
ip
:
ip
=
ip
+
':8000/report.html'
else
:
ip
=
'https://www.baidu.com'
return
ip
webhook
=
webhookHandler
()
\ No newline at end of file
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