Commit 839d5af5 authored by 黎博's avatar 黎博

发送BUG通知时新增项目所属BUG提醒

parent 73d07d6d
......@@ -7,6 +7,7 @@ import cn.qg.holmes.mapper.quality.DingRobotMapper;
import cn.qg.holmes.service.quality.JiraBugPoolService;
import cn.qg.holmes.service.quality.WebhookService;
import cn.qg.holmes.utils.DingdingUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jayway.jsonpath.JsonPath;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -214,34 +215,39 @@ public class WebhookServiceImpl implements WebhookService {
String robotUrl = null;
Integer dingRobotId = null;
Integer status = null;
List<DingRobot> dingRobots = dingRobotMapper.selectList(null);
for (DingRobot dingRobot : dingRobots) {
String projectName = "【" + dingRobot.getProjectName() + "】";
if (summary.contains(projectName)) {
robotUrl = dingRobot.getDingUrl();
dingRobotId = dingRobot.getId();
status = dingRobot.getStatus();
break;
QueryWrapper<DingRobot> dingRobotQueryWrapper = new QueryWrapper<>();
dingRobotQueryWrapper.eq("jira_project_key", key.split("-")[0]);
List<DingRobot> dingRobots = dingRobotMapper.selectList(dingRobotQueryWrapper);
if (dingRobots.size() > 0) {
for (DingRobot dingRobot : dingRobots) {
String projectName = "【" + dingRobot.getProjectName() + "】";
if (summary.contains(projectName)) {
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;
......
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