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
f278aa17
Commit
f278aa17
authored
Sep 23, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG通知新增条件判断
parent
b80fc74d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
DingRobotServiceImpl.java
.../cn/qg/holmes/service/jira/impl/DingRobotServiceImpl.java
+8
-2
JiraToDingding.java
src/main/java/cn/qg/holmes/task/jira/JiraToDingding.java
+10
-1
No files found.
src/main/java/cn/qg/holmes/service/jira/impl/DingRobotServiceImpl.java
View file @
f278aa17
...
@@ -42,16 +42,20 @@ public class DingRobotServiceImpl extends ServiceImpl<DingRobotMapper, DingRobot
...
@@ -42,16 +42,20 @@ public class DingRobotServiceImpl extends ServiceImpl<DingRobotMapper, DingRobot
String
priority
=
JsonPath
.
read
(
jiraData
,
"$.issue.fields.priority.name"
);
String
priority
=
JsonPath
.
read
(
jiraData
,
"$.issue.fields.priority.name"
);
String
module
=
JsonPath
.
read
(
jiraData
,
"$.issue.fields.components[0].name"
);
String
module
=
JsonPath
.
read
(
jiraData
,
"$.issue.fields.components[0].name"
);
String
robotUrl
=
null
;
String
robotUrl
=
null
;
Integer
dingRobotId
=
null
;
Integer
status
=
null
;
List
<
DingRobot
>
dingRobots
=
dingRobotMapper
.
selectList
(
null
);
List
<
DingRobot
>
dingRobots
=
dingRobotMapper
.
selectList
(
null
);
for
(
DingRobot
dingRobot
:
dingRobots
)
{
for
(
DingRobot
dingRobot
:
dingRobots
)
{
String
projectName
=
"【"
+
dingRobot
.
getProjectName
()
+
"】"
;
String
projectName
=
"【"
+
dingRobot
.
getProjectName
()
+
"】"
;
if
(
summary
.
contains
(
projectName
))
{
if
(
summary
.
contains
(
projectName
))
{
robotUrl
=
dingRobot
.
getDingUrl
();
robotUrl
=
dingRobot
.
getDingUrl
();
dingRobotId
=
dingRobot
.
getId
();
status
=
dingRobot
.
getStatus
();
break
;
break
;
}
}
}
}
// 只有创建了dingRobot的项目的BUG才会被放到BUG池子里
// 只有创建了dingRobot的项目的BUG才会被放到BUG池子里
if
(
robotUrl
!=
null
)
{
if
(
robotUrl
!=
null
&&
dingRobotId
!=
null
)
{
// 首次提交的BUG放入bug池子
// 首次提交的BUG放入bug池子
JiraBugPool
jiraBugPool
=
new
JiraBugPool
();
JiraBugPool
jiraBugPool
=
new
JiraBugPool
();
jiraBugPool
.
setKey
(
key
);
jiraBugPool
.
setKey
(
key
);
...
@@ -61,9 +65,11 @@ public class DingRobotServiceImpl extends ServiceImpl<DingRobotMapper, DingRobot
...
@@ -61,9 +65,11 @@ public class DingRobotServiceImpl extends ServiceImpl<DingRobotMapper, DingRobot
jiraBugPool
.
setAssignee
(
assignee
);
jiraBugPool
.
setAssignee
(
assignee
);
jiraBugPool
.
setUrl
(
"http://jira2.quantgroup.cn/browse/"
+
key
);
jiraBugPool
.
setUrl
(
"http://jira2.quantgroup.cn/browse/"
+
key
);
jiraBugPool
.
setDingUrl
(
robotUrl
);
jiraBugPool
.
setDingUrl
(
robotUrl
);
jiraBugPool
.
setDingRobotId
(
dingRobotId
);
jiraBugPoolService
.
save
(
jiraBugPool
);
jiraBugPoolService
.
save
(
jiraBugPool
);
}
}
if
(
robotUrl
!=
null
)
{
// 只有项目是进行中才会发送通知
if
(
robotUrl
!=
null
&&
status
==
1
)
{
String
markdownMsg
=
DingdingUtils
.
buildBugCommitMarkdownMsg
(
key
,
summary
,
creator
,
assignee
,
priority
,
module
);
String
markdownMsg
=
DingdingUtils
.
buildBugCommitMarkdownMsg
(
key
,
summary
,
creator
,
assignee
,
priority
,
module
);
return
DingdingUtils
.
sendToDingding
(
markdownMsg
,
robotUrl
);
return
DingdingUtils
.
sendToDingding
(
markdownMsg
,
robotUrl
);
}
}
...
...
src/main/java/cn/qg/holmes/task/jira/JiraToDingding.java
View file @
f278aa17
package
cn
.
qg
.
holmes
.
task
.
jira
;
package
cn
.
qg
.
holmes
.
task
.
jira
;
import
cn.qg.holmes.entity.jira.DingRobot
;
import
cn.qg.holmes.entity.jira.JiraBugPool
;
import
cn.qg.holmes.entity.jira.JiraBugPool
;
import
cn.qg.holmes.service.jira.DingRobotService
;
import
cn.qg.holmes.service.jira.JiraBugPoolService
;
import
cn.qg.holmes.service.jira.JiraBugPoolService
;
import
cn.qg.holmes.service.jira.JiraIssueService
;
import
cn.qg.holmes.service.jira.JiraIssueService
;
import
cn.qg.holmes.utils.DingdingUtils
;
import
cn.qg.holmes.utils.DingdingUtils
;
...
@@ -28,6 +30,9 @@ public class JiraToDingding {
...
@@ -28,6 +30,9 @@ public class JiraToDingding {
@Autowired
@Autowired
JiraBugPoolService
jiraBugPoolService
;
JiraBugPoolService
jiraBugPoolService
;
@Autowired
DingRobotService
dingRobotService
;
@Value
(
"${sjgd.ding.url}"
)
@Value
(
"${sjgd.ding.url}"
)
private
String
sjgdDingUrl
;
private
String
sjgdDingUrl
;
...
@@ -80,7 +85,11 @@ public class JiraToDingding {
...
@@ -80,7 +85,11 @@ public class JiraToDingding {
log
.
info
(
"{} BUG持续时间:{}小时"
,
issue
.
getKey
(),
duration
);
log
.
info
(
"{} BUG持续时间:{}小时"
,
issue
.
getKey
(),
duration
);
// 如果已超过4个小时,则发送钉钉通知
// 如果已超过4个小时,则发送钉钉通知
if
(
duration
>=
4
)
{
if
(
duration
>=
4
)
{
DingdingUtils
.
sendToDingding
(
DingdingUtils
.
buildBugFixRemindMsg
(
issue
,
duration
),
jiraBugPool
.
getDingUrl
());
DingRobot
dingRobot
=
dingRobotService
.
getById
(
jiraBugPool
.
getDingRobotId
());
// 项目进行中才发送通知
if
(
dingRobot
.
getStatus
()
==
1
)
{
DingdingUtils
.
sendToDingding
(
DingdingUtils
.
buildBugFixRemindMsg
(
issue
,
duration
),
jiraBugPool
.
getDingUrl
());
}
}
}
}
}
}
else
{
}
else
{
...
...
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