diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java index da79ff5da1..e0e7abcf8b 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java @@ -12,6 +12,7 @@ import io.metersphere.base.domain.ApiTestCaseWithBLOBs; import io.metersphere.base.domain.ApiTestEnvironment; import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.OperLogConstants; +import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.controller.request.ResetOrderRequest; @@ -192,6 +193,7 @@ public class ApiTestCaseController { @PostMapping(value = "/batch/run") @MsAuditLog(module = "api_definition_case", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.caseId)", msClass = ApiTestCaseService.class) public void batchRun(@RequestBody ApiCaseRunRequest request) { + request.setTriggerMode(ReportTriggerMode.BATCH.name()); apiTestCaseService.batchRun(request); } diff --git a/backend/src/main/java/io/metersphere/api/dto/ApiCaseRunRequest.java b/backend/src/main/java/io/metersphere/api/dto/ApiCaseRunRequest.java index 81323d7bf5..65c3ecbbe3 100644 --- a/backend/src/main/java/io/metersphere/api/dto/ApiCaseRunRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/ApiCaseRunRequest.java @@ -11,6 +11,7 @@ import java.util.List; @Setter public class ApiCaseRunRequest { private String reportId; + private String triggerMode; private String id; private List ids; private List orders; diff --git a/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java b/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java index 835e528bca..b9228b5897 100644 --- a/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java +++ b/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java @@ -91,6 +91,7 @@ public class ApiExecuteService { for (ApiTestCaseWithBLOBs caseWithBLOBs : list) { ApiDefinitionExecResult report = ApiDefinitionExecResultUtil.initBase(caseWithBLOBs.getId(), APITestStatus.Running.name(), null); report.setName(caseWithBLOBs.getName()); + report.setTriggerMode(request.getTriggerMode()); caseWithBLOBs.setLastResultId(report.getId()); caseWithBLOBs.setUpdateTime(System.currentTimeMillis()); caseWithBLOBs.setStatus(APITestStatus.Running.name()); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index 7ad7ebe403..2f1fe350b0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -325,11 +325,7 @@ public class ApiDefinitionExecResultService { saveResult.setId(reportId); saveResult.setActuator("LOCAL"); saveResult.setName(item.getName()); - if (StringUtils.equals(type, ApiRunMode.JENKINS_API_PLAN.name())) { - saveResult.setTriggerMode(TriggerMode.API.name()); - } else if (StringUtils.equals(type, ApiRunMode.MANUAL_PLAN.name())) { - saveResult.setTriggerMode(TriggerMode.MANUAL.name()); - } else { + if (StringUtils.equals(type, TriggerMode.SCHEDULE.name())) { saveResult.setTriggerMode(TriggerMode.SCHEDULE.name()); } saveResult.setType(type); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 76fe1dd978..4fbf3c3e00 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -768,7 +768,7 @@ public class ApiTestCaseService { //提前生成报告 ApiDefinitionExecResult report = ApiDefinitionExecResultUtil.add(caseWithBLOBs.getId(), APITestStatus.Running.name(), request.getReportId()); report.setName(caseWithBLOBs.getName()); - report.setTriggerMode(ApiRunMode.API.name()); + report.setTriggerMode(ApiRunMode.JENKINS.name()); report.setType(ApiRunMode.JENKINS.name()); apiDefinitionExecResultMapper.insert(report); //更新接口案例的最后执行状态等信息