From 90097464948e1b2fd102d27370e62db6ecf1a9b7 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 28 Jan 2021 17:35:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20jenkins=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=94=B6=E4=B8=8D=E5=88=B0=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/jmeter/APIBackendListenerClient.java | 3 +++ .../track/controller/TestPlanController.java | 5 +++++ .../request/testplan/TestplanRunRequest.java | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 backend/src/main/java/io/metersphere/track/request/testplan/TestplanRunRequest.java diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index 94878518be..81fb282d65 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -177,6 +177,9 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl } else if (StringUtils.equals(this.runMode, ApiRunMode.JENKINS.name())) { apiDefinitionService.addResult(testResult); apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.DEFINITION.name()); + apiTestService.changeStatus(testId, APITestStatus.Completed); + report = apiReportService.getRunningReport(testResult.getTestId()); + apiReportService.complete(testResult, report); } else if (StringUtils.equalsAny(this.runMode, ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name())) { apiDefinitionService.addResult(testResult); diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 5b99d9a620..84edbe995d 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -15,6 +15,7 @@ import io.metersphere.track.dto.TestPlanDTOWithMetric; import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testplan.AddTestPlanRequest; +import io.metersphere.track.request.testplan.TestplanRunRequest; import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest; import io.metersphere.track.service.TestPlanProjectService; import io.metersphere.track.service.TestPlanService; @@ -136,4 +137,8 @@ public class TestPlanController { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, testPlanProjectService.getProjectByPlanId(request)); } + @PostMapping("/testplan/jenkins") + public void runJenkins(@RequestBody TestplanRunRequest testplanRunRequest){ + testPlanService.run(testplanRunRequest.getTestPlanID(),testplanRunRequest.getProjectID(),testplanRunRequest.getUserId(),testplanRunRequest.getTriggerMode()); + } } diff --git a/backend/src/main/java/io/metersphere/track/request/testplan/TestplanRunRequest.java b/backend/src/main/java/io/metersphere/track/request/testplan/TestplanRunRequest.java new file mode 100644 index 0000000000..016c73e65f --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/request/testplan/TestplanRunRequest.java @@ -0,0 +1,15 @@ +package io.metersphere.track.request.testplan; + + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class TestplanRunRequest { + private String testPlanID; + private String projectID; + private String userId; + private String triggerMode; +} +