Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
holmes
Commits
839d5af5
Commit
839d5af5
authored
Feb 21, 2022
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送BUG通知时新增项目所属BUG提醒
parent
73d07d6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
27 deletions
+33
-27
WebhookServiceImpl.java
...cn/qg/holmes/service/quality/impl/WebhookServiceImpl.java
+33
-27
No files found.
src/main/java/cn/qg/holmes/service/quality/impl/WebhookServiceImpl.java
View file @
839d5af5
...
@@ -7,6 +7,7 @@ import cn.qg.holmes.mapper.quality.DingRobotMapper;
...
@@ -7,6 +7,7 @@ import cn.qg.holmes.mapper.quality.DingRobotMapper;
import
cn.qg.holmes.service.quality.JiraBugPoolService
;
import
cn.qg.holmes.service.quality.JiraBugPoolService
;
import
cn.qg.holmes.service.quality.WebhookService
;
import
cn.qg.holmes.service.quality.WebhookService
;
import
cn.qg.holmes.utils.DingdingUtils
;
import
cn.qg.holmes.utils.DingdingUtils
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.jayway.jsonpath.JsonPath
;
import
com.jayway.jsonpath.JsonPath
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -214,34 +215,39 @@ public class WebhookServiceImpl implements WebhookService {
...
@@ -214,34 +215,39 @@ public class WebhookServiceImpl implements WebhookService {
String
robotUrl
=
null
;
String
robotUrl
=
null
;
Integer
dingRobotId
=
null
;
Integer
dingRobotId
=
null
;
Integer
status
=
null
;
Integer
status
=
null
;
List
<
DingRobot
>
dingRobots
=
dingRobotMapper
.
selectList
(
null
);
QueryWrapper
<
DingRobot
>
dingRobotQueryWrapper
=
new
QueryWrapper
<>();
for
(
DingRobot
dingRobot
:
dingRobots
)
{
dingRobotQueryWrapper
.
eq
(
"jira_project_key"
,
key
.
split
(
"-"
)[
0
]);
String
projectName
=
"【"
+
dingRobot
.
getProjectName
()
+
"】"
;
List
<
DingRobot
>
dingRobots
=
dingRobotMapper
.
selectList
(
dingRobotQueryWrapper
);
if
(
summary
.
contains
(
projectName
))
{
if
(
dingRobots
.
size
()
>
0
)
{
robotUrl
=
dingRobot
.
getDingUrl
();
for
(
DingRobot
dingRobot
:
dingRobots
)
{
dingRobotId
=
dingRobot
.
getId
();
String
projectName
=
"【"
+
dingRobot
.
getProjectName
()
+
"】"
;
status
=
dingRobot
.
getStatus
();
if
(
summary
.
contains
(
projectName
))
{
break
;
robotUrl
=
dingRobot
.
getDingUrl
();
dingRobotId
=
dingRobot
.
getId
();
status
=
dingRobot
.
getStatus
();
break
;
}
}
// 只有创建了dingRobot的项目的BUG才会被放到BUG池子里
if
(
robotUrl
!=
null
&&
dingRobotId
!=
null
)
{
// 首次提交的BUG放入bug池子
JiraBugPool
jiraBugPool
=
new
JiraBugPool
();
jiraBugPool
.
setKey
(
key
);
jiraBugPool
.
setSummary
(
summary
);
jiraBugPool
.
setPriority
(
priority
);
jiraBugPool
.
setReporter
(
creator
);
jiraBugPool
.
setAssignee
(
assignee
);
jiraBugPool
.
setUrl
(
"http://jira2.quantgroup.cn/browse/"
+
key
);
jiraBugPool
.
setDingUrl
(
robotUrl
);
jiraBugPool
.
setDingRobotId
(
dingRobotId
);
jiraBugPoolService
.
save
(
jiraBugPool
);
}
// 只有项目是进行中才会发送通知
if
(
robotUrl
!=
null
&&
status
==
1
)
{
String
markdownMsg
=
DingdingUtils
.
buildBugCommitMarkdownMsg
(
key
,
summary
,
creator
,
assignee
,
priority
,
module
);
return
DingdingUtils
.
sendToDingding
(
markdownMsg
,
robotUrl
);
}
}
}
// 只有创建了dingRobot的项目的BUG才会被放到BUG池子里
if
(
robotUrl
!=
null
&&
dingRobotId
!=
null
)
{
// 首次提交的BUG放入bug池子
JiraBugPool
jiraBugPool
=
new
JiraBugPool
();
jiraBugPool
.
setKey
(
key
);
jiraBugPool
.
setSummary
(
summary
);
jiraBugPool
.
setPriority
(
priority
);
jiraBugPool
.
setReporter
(
creator
);
jiraBugPool
.
setAssignee
(
assignee
);
jiraBugPool
.
setUrl
(
"http://jira2.quantgroup.cn/browse/"
+
key
);
jiraBugPool
.
setDingUrl
(
robotUrl
);
jiraBugPool
.
setDingRobotId
(
dingRobotId
);
jiraBugPoolService
.
save
(
jiraBugPool
);
}
// 只有项目是进行中才会发送通知
if
(
robotUrl
!=
null
&&
status
==
1
)
{
String
markdownMsg
=
DingdingUtils
.
buildBugCommitMarkdownMsg
(
key
,
summary
,
creator
,
assignee
,
priority
,
module
);
return
DingdingUtils
.
sendToDingding
(
markdownMsg
,
robotUrl
);
}
}
}
}
return
false
;
return
false
;
...
...
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