fix: 添加负责人字段,修改消息通知内容 (#5076)

Co-authored-by: wenyann <wenyan.yang@fit2cloud.com>
This commit is contained in:
metersphere-bot 2021-07-27 14:02:51 +08:00 committed by GitHub
parent 030a53bac9
commit 0f3be78cdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 7 deletions

View File

@ -8,4 +8,5 @@ public class ApiTestReportVariable extends ApiTestReport {
public String executionTime;
public String executor;
public String executionEnvironment;
public String principal;
}

View File

@ -114,6 +114,8 @@ public class TestResultService {
}
//执行人
String userName = apiAutomationService.getUser(apiScenario.getUserId());
//负责人
String principal = apiAutomationService.getUser(apiScenario.getPrincipal());
//报告内容
reportTask = new ApiTestReportVariable();
reportTask.setStatus(scenarioReport.getStatus());
@ -121,6 +123,7 @@ public class TestResultService {
reportTask.setTriggerMode(scenarioReport.getTriggerMode());
reportTask.setName(scenarioReport.getName());
reportTask.setExecutor(userName);
reportTask.setPrincipal(principal);
reportTask.setExecutionTime(DateUtils.getTimeString(scenarioReport.getUpdateTime()));
reportTask.setExecutionEnvironment(name);
SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class);
@ -202,13 +205,13 @@ public class TestResultService {
String subject = "";
String event = "";
if (StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())) {
successContext = "接口测试 API任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行成功" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
failedContext = "接口测试 API任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行失败" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
successContext = "接口测试 API任务通知:jenkins所执行的" + report.getName() + "'执行成功" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
failedContext = "接口测试 API任务通知:jenkins所执行的" + report.getName() + "'执行失败" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
subject = Translator.get("task_notification_jenkins");
}
if (StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), report.getTriggerMode())) {
successContext = "接口测试定时任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行成功" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
failedContext = "接口测试定时任务通知:'" + report.getExecutor() + "所执行的" + report.getName() + "'执行失败" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
successContext = "接口测试定时任务通知:定时任务所执行的" + report.getName() + "'执行成功" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
failedContext = "接口测试定时任务通知:定时任务所执行的" + report.getName() + "'执行失败" + "\n" + "执行环境:" + report.getExecutionEnvironment() + "\n" + "[接口定义暂无报告链接]" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2;
subject = Translator.get("task_notification");
}
if (StringUtils.equals("Success", report.getStatus())) {
@ -232,6 +235,7 @@ public class TestResultService {
paramMap.put("executor", report.getExecutor());
paramMap.put("executionTime", report.getExecutionTime());
paramMap.put("executionEnvironment", report.getExecutionEnvironment());
paramMap.put("principal", report.getPrincipal());
NoticeModel noticeModel = NoticeModel.builder()
.successContext(successContext)
.successMailTemplate("ApiSuccessfulNotification")

View File

@ -168,7 +168,9 @@ export default {
' <p style="margin-left: 60px">您好:\n' +
' </div>\n' +
' <div style="margin-left: 100px">\n' +
' <p>${executor}所执行的 ${testName} 接口测试运行失败<br/>\n' +
' <p>${testName} 接口测试运行失败<br/>\n' +
' <p>执行人:${executor}</p>' +
' <p>负责人:${principal}</p>' +
' <p>执行环境:${executionEnvironment}</p>' +
' <p>执行时间:${executionTime}</p>' +
' 请点击下面链接进入测试报告页面</p>\n' +
@ -181,7 +183,9 @@ export default {
'</body>\n' +
'</html>',
robotTitle:
"测试【任务通知】:'${executor}所执行的 ${testName} ${type}测试运行${status}\n" +
"测试【任务通知】:'${testName} ${type}测试运行${status}\n" +
"执行人:${executor}" + "\n" +
"负责人:${principal}" + "\n" +
"测试环境为:${executionEnvironment}\n" +
"执行时间:${executionTime}\n" +
"请点击下面链接进入测试报告页面\n" +

View File

@ -169,6 +169,7 @@ export default {
' <div style="margin-left: 100px">\n' +
' <p>${testName} 接口测试运行失败/成功<br/>\n' +
' <p>执行人:${executor}</p>' +
' <p>负责人:${principal}</p>' +
' <p>执行环境:${executionEnvironment}</p>' +
' <p>执行时间:${executionTime}</p>' +
' 请点击下面链接进入测试报告页面</p>\n' +
@ -181,7 +182,9 @@ export default {
'</body>\n' +
'</html>',
robotTitle:
"测试【任务通知】:'${executor}所执行的 ${testName} ${type}测试运行${status}," + "\n" +
"测试【任务通知】:'${testName} ${type}测试运行${status}," + "\n" +
"执行人:${executor}" + "\n" +
"负责人:${principal}" + "\n" +
"测试环境为:${executionEnvironment}" + "\n" +
"执行时间:${executionTime}" + "\n" +
"请点击下面链接进入测试报告页面" + "\n" +