fix: 修复jenkins消息通知没有替换变量的问题

This commit is contained in:
Captain.B 2020-12-09 10:26:02 +08:00
parent 3e15d419fb
commit 2fe673af83
2 changed files with 15 additions and 3 deletions

View File

@ -229,7 +229,11 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
if (StringUtils.equals("Error", report.getStatus())) { if (StringUtils.equals("Error", report.getStatus())) {
event = NoticeConstants.Event.EXECUTE_FAILED; event = NoticeConstants.Event.EXECUTE_FAILED;
} }
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("testName", report.getName());
paramMap.put("id", report.getId());
paramMap.put("type", "performance");
paramMap.put("url", baseSystemConfigDTO.getUrl());
NoticeModel noticeModel = NoticeModel.builder() NoticeModel noticeModel = NoticeModel.builder()
.successContext(successContext) .successContext(successContext)
.successMailTemplate("ApiSuccessfulNotification") .successMailTemplate("ApiSuccessfulNotification")
@ -239,6 +243,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
.status(report.getStatus()) .status(report.getStatus())
.event(event) .event(event)
.subject(subject) .subject(subject)
.paramMap(paramMap)
.build(); .build();
noticeSendService.send(report.getTriggerMode(), noticeModel); noticeSendService.send(report.getTriggerMode(), noticeModel);
} }

View File

@ -15,6 +15,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -49,7 +51,7 @@ public class PerformanceNoticeTask {
} }
try { try {
//查询定时任务是否关闭 //查询定时任务是否关闭
Thread.sleep(1000 * 30);// 每分钟检查 loadtest 的状态 Thread.sleep(1000 * 10);// 检查 loadtest 的状态
} catch (InterruptedException e) { } catch (InterruptedException e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
} }
@ -81,7 +83,11 @@ public class PerformanceNoticeTask {
if (PerformanceTestStatus.Error.name().equals(loadTestReport.getStatus())) { if (PerformanceTestStatus.Error.name().equals(loadTestReport.getStatus())) {
event = NoticeConstants.Event.EXECUTE_FAILED; event = NoticeConstants.Event.EXECUTE_FAILED;
} }
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("testName", loadTestReport.getName());
paramMap.put("id", loadTestReport.getId());
paramMap.put("type", "performance");
paramMap.put("url", baseSystemConfigDTO.getUrl());
NoticeModel noticeModel = NoticeModel.builder() NoticeModel noticeModel = NoticeModel.builder()
.successContext(successContext) .successContext(successContext)
.successMailTemplate("PerformanceApiSuccessNotification") .successMailTemplate("PerformanceApiSuccessNotification")
@ -91,6 +97,7 @@ public class PerformanceNoticeTask {
.status(loadTestReport.getStatus()) .status(loadTestReport.getStatus())
.subject(subject) .subject(subject)
.event(event) .event(event)
.paramMap(paramMap)
.build(); .build();
noticeSendService.send(loadTestReport.getTriggerMode(), noticeModel); noticeSendService.send(loadTestReport.getTriggerMode(), noticeModel);
} }