fix:定时,jenkins场景执行发消息报错
This commit is contained in:
parent
7f33a80ad7
commit
7d9d958fcf
|
@ -237,7 +237,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
TestPlanApiCase testPlanApiCase = testPlanApiCaseService.getInfo(testResult.getTestId(), debugReportId);
|
||||
String name = apiAutomationService.get(testPlanApiCase.getEnvironmentId()).getName();
|
||||
//时间
|
||||
Long time = apiTestCaseWithBLOBs.getUpdateTime();
|
||||
Long time = apiTestCaseWithBLOBs.getCreateTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String executionTime = null;
|
||||
String time_ = String.valueOf(time);
|
||||
|
@ -250,8 +250,13 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
|
||||
//报告内容
|
||||
reportTask = new ApiTestReportVariable();
|
||||
reportTask.setStatus(apiResult.getStatus());
|
||||
reportTask.setId(apiResult.getId());
|
||||
if (null != apiResult) {
|
||||
reportTask.setStatus(apiResult.getStatus());
|
||||
reportTask.setId(apiResult.getId());
|
||||
} else {
|
||||
reportTask.setStatus(testPlanApiCase.getStatus());
|
||||
reportTask.setId(testPlanApiCase.getId());
|
||||
}
|
||||
reportTask.setTriggerMode("API");
|
||||
reportTask.setName(apiTestCaseWithBLOBs.getName());
|
||||
reportTask.setExecutor(userName);
|
||||
|
@ -280,22 +285,24 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
ApiScenarioWithBLOBs apiScenario = apiAutomationService.getDto(scenarioReport.getScenarioId());
|
||||
String executionEnvironment = apiScenario.getScenarioDefinition();
|
||||
JSONObject json = JSONObject.parseObject(executionEnvironment);
|
||||
JSONObject environment = JSONObject.parseObject(json.getString("environmentMap"));
|
||||
String environmentId = environment.get(apiScenario.getProjectId()).toString();
|
||||
String name = apiAutomationService.get(environmentId).getName();
|
||||
String name = "";
|
||||
if (json.getString("environmentMap").length() > 0) {
|
||||
JSONObject environment = JSONObject.parseObject(json.getString("environmentMap"));
|
||||
String environmentId = environment.get(apiScenario.getProjectId()).toString();
|
||||
name = apiAutomationService.get(environmentId).getName();
|
||||
}
|
||||
|
||||
|
||||
//时间
|
||||
Long time = apiScenario.getUpdateTime();
|
||||
Long time = scenarioReport.getUpdateTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String executionTime = null;
|
||||
String time_ = String.valueOf(time);
|
||||
if (!time_.equals("null")) {
|
||||
executionTime = sdf.format(new Date(Long.parseLong(time_)));
|
||||
}
|
||||
|
||||
//执行人
|
||||
String userName = apiAutomationService.getUser(apiScenario.getUserId()).getName();
|
||||
|
||||
//报告内容
|
||||
reportTask = new ApiTestReportVariable();
|
||||
reportTask.setStatus(scenarioReport.getStatus());
|
||||
|
@ -309,7 +316,6 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
assert systemParameterService != null;
|
||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||
reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report";
|
||||
|
||||
testResult.setTestId(scenarioReport.getScenarioId());
|
||||
} else {
|
||||
apiTestService.changeStatus(testId, APITestStatus.Completed);
|
||||
|
|
|
@ -41,6 +41,7 @@ public class ApiDefinitionExecResultService {
|
|||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
private TestCaseReviewApiCaseService testCaseReviewApiCaseService;
|
||||
|
||||
@Resource
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ public class TestPlanScenarioCaseService {
|
|||
request.setRunMode(ApiRunMode.SCENARIO_PLAN.name());
|
||||
request.setId(testPlanScenarioRequest.getId());
|
||||
request.setExecuteType(ExecuteType.Saved.name());
|
||||
request.setTriggerMode(testPlanScenarioRequest.getTriggerMode());
|
||||
return apiAutomationService.run(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ export default {
|
|||
' 请点击下面链接进入测试报告页面</p>\n' +
|
||||
' <a href="${url}/#/${type}/report/view/${id}">${url}/#/${type}/report/view/${id}</a>\n' +
|
||||
' <p>新版接口测试报告路径</p>\n' +
|
||||
' <a href="${url}/#/api/automation">${url}/#/api/automation</a>\n' +
|
||||
' <a href="${url}/#/api/automation/report/view/">${url}/#/api/automation/report/view/${id}</a>\n' +
|
||||
' </div>\n' +
|
||||
'\n' +
|
||||
'</div>\n' +
|
||||
|
@ -186,12 +186,12 @@ export default {
|
|||
'</html>',
|
||||
robotTitle:
|
||||
"测试【任务通知】:'${executor}所执行的 ${testName} ${type}测试运行${status}\n" +
|
||||
"测试环境为:${executionEnvironment}," +
|
||||
"测试环境为:${executionEnvironment}\n" +
|
||||
"执行时间:${executionTime}\n" +
|
||||
"请点击下面链接进入测试报告页面\n" +
|
||||
"${url}/#/${type}/report/view/${id}" +
|
||||
"新版接口测试报告路径\n" +
|
||||
"${url}/#/api/automation",
|
||||
"${url}/#/api/automation/report/view/${id}",
|
||||
scheduleTask: [{
|
||||
taskType: "scheduleTask",
|
||||
event: "",
|
||||
|
|
|
@ -177,20 +177,20 @@ export default {
|
|||
' 请点击下面链接进入测试报告页面</p>\n' +
|
||||
' <a href="${url}/#/${type}/report/view/${id}">${url}/#/${type}/report/view/${id}</a>\n' +
|
||||
' <p>新版接口测试报告路径</p>\n' +
|
||||
' <a href="${url}/#/api/automation">${url}/#/api/automation</a>\n' +
|
||||
' <a href="${url}/#/api/automation/report/view/">${url}/#/api/automation/report/view/${id}</a>\n' +
|
||||
' </div>\n' +
|
||||
'\n' +
|
||||
'</div>\n' +
|
||||
'</body>\n' +
|
||||
'</html>',
|
||||
robotTitle:
|
||||
"测试【任务通知】:'${executor}所执行的 ${testName} ${type}测试运行${status}," +
|
||||
"测试环境为:${executionEnvironment}," +
|
||||
"测试【任务通知】:'${executor}所执行的 ${testName} ${type}测试运行${status}\n" +
|
||||
"测试环境为:${executionEnvironment}\n" +
|
||||
"执行时间:${executionTime}\n" +
|
||||
"请点击下面链接进入测试报告页面\n" +
|
||||
"${url}/#/${type}/report/view/${id}" +
|
||||
"新版接口测试报告路径\n" +
|
||||
"${url}/#/api/automation",
|
||||
"${url}/#/api/automation/report/view/${id}",
|
||||
jenkinsTask: [{
|
||||
taskType: "jenkinsTask",
|
||||
event: "",
|
||||
|
|
|
@ -178,20 +178,20 @@ export default {
|
|||
' 请点击下面链接进入测试报告页面</p>\n' +
|
||||
' <a href="${url}/#/${type}/report/view/${id}">${url}/#/${type}/report/view/${id}</a>\n' +
|
||||
' <p>新版接口测试报告路径</p>\n' +
|
||||
' <a href="${url}/#/api/automation">${url}/#/api/automation</a>\n' +
|
||||
' <a href="${url}/#/api/automation/report/view/">${url}/#/api/automation/report/view/${id}</a>\n' +
|
||||
' </div>\n' +
|
||||
'\n' +
|
||||
'</div>\n' +
|
||||
'</body>\n' +
|
||||
'</html>',
|
||||
robotTitle:
|
||||
"测试【任务通知】:'${executor}所执行的 ${testName} ${type}测试运行${status}," +
|
||||
"测试环境为:${executionEnvironment}," +
|
||||
"执行时间:${executionTime}\n" +
|
||||
"请点击下面链接进入测试报告页面\n" +
|
||||
"${url}/#/${type}/report/view/${id}" +
|
||||
"新版接口测试报告路径\n" +
|
||||
"${url}/#/api/automation",
|
||||
"测试【任务通知】:'${executor}所执行的 ${testName} ${type}测试运行${status}," + "\n" +
|
||||
"测试环境为:${executionEnvironment}" + "\n" +
|
||||
"执行时间:${executionTime}" + "\n" +
|
||||
"请点击下面链接进入测试报告页面" + "\n" +
|
||||
"${url}/#/${type}/report/view/${id}" + "\n" +
|
||||
"新版接口测试报告路径" + "\n" +
|
||||
"${url}/#/api/automation/report/view/${id}",
|
||||
scheduleTask: [{
|
||||
taskType: "scheduleTask",
|
||||
event: "",
|
||||
|
|
Loading…
Reference in New Issue