From 144de4b950ab7c94c24caf4042a7d4d56bb61d5a Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 7 Jun 2022 13:49:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Djenkins=E6=89=A7=E8=A1=8C=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E4=BC=9A=E5=8F=91=E9=80=81=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1013358 --user=宋天阳 【消息通知】用jenkins 跑一个包含100+ 场景的测试计划,邮箱收到100+条通知,建议只接收执行该测试计划的一个通知 https://www.tapd.cn/55049933/s/1174780 --- .../api/service/ApiScenarioReportService.java | 19 +++++++++++++++---- .../tableItem/ReportTriggerModeItem.vue | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index e81884ba64..9be31f37bd 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -33,6 +33,7 @@ import io.metersphere.track.dto.PlanReportCaseDTO; import io.metersphere.utils.LoggerUtil; import org.apache.commons.beanutils.BeanMap; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -162,6 +163,7 @@ public class ApiScenarioReportService { } public List list(QueryAPIReportRequest request) { + request = this.initRequest(request); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); List list = extApiScenarioReportMapper.list(request); List userIds = list.stream().map(APIScenarioReportResult::getUserId) @@ -175,7 +177,20 @@ public class ApiScenarioReportService { return list; } + public QueryAPIReportRequest initRequest(QueryAPIReportRequest request){ + if(request != null){ + //初始化triggerMode的查询条件: 如果查询API的话,增加 JENKINS_RUN_TEST_PLAN(jenkins调用测试计划时执行的场景) 查询条件 + if(MapUtils.isNotEmpty(request.getFilters()) && request.getFilters().containsKey("trigger_mode") + && CollectionUtils.isNotEmpty(request.getFilters().get("trigger_mode")) + && request.getFilters().get("trigger_mode").contains("API") && !request.getFilters().get("trigger_mode").contains(ReportTriggerMode.JENKINS_RUN_TEST_PLAN.name())){ + request.getFilters().get("trigger_mode").add(ReportTriggerMode.JENKINS_RUN_TEST_PLAN.name()); + } + } + return request; + } + public List idList(QueryAPIReportRequest request) { + request = this.initRequest(request); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); return extApiScenarioReportMapper.idList(request); } @@ -224,10 +239,6 @@ public class ApiScenarioReportService { if (StringUtils.equals(reportType, RunModeConstants.SET_REPORT.toString())) { return report; } - if(StringUtils.equalsAnyIgnoreCase(report.getTriggerMode(),ReportTriggerMode.JENKINS_RUN_TEST_PLAN.name())){ - //jenkins运行测试计划时执行的场景,触发方式改回API - report.setTriggerMode(ReportTriggerMode.API.name()); - } if (runMode.equals("CASE")) { report.setTriggerMode(TriggerMode.MANUAL.name()); } diff --git a/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue b/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue index 4fc1eed866..45ec0f71d8 100644 --- a/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue +++ b/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue @@ -5,6 +5,7 @@ {{$t('commons.trigger_mode.test_plan_schedule')}} {{$t('commons.trigger_mode.test_plan_api')}} {{$t('commons.trigger_mode.api')}} + {{$t('commons.trigger_mode.api')}} {{$t('api_test.automation.batch_execute')}}