Explorar o código

Merge branch 'dev_pipeline' into dev

Jinyao %!s(int64=5) %!d(string=hai) anos
pai
achega
046d0077cf

+ 10 - 17
mock/routers/pipeline.js

@@ -42,16 +42,6 @@ router.get('/history/list', (req, res) => {
     Mock.mock(
     Mock.mock(
       {
       {
         'data|10': [{
         'data|10': [{
-          details: `2021-03-16 00:01:58.621  INFO 20584 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
-2021-03-16 00:01:58.622  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
-2021-03-16 00:01:58.634  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
-2021-03-16 00:01:58.641  INFO 20584 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
-2021-03-16 00:01:58.974  INFO 20584 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
-2021-03-16 00:01:58.975  INFO 20584 --- [           main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
-2021-03-16 00:01:58.993  INFO 20584 --- [           main] s.devcloud.web.DevcloudWebApplication    : Started DevcloudWebApplication in 6.659 seconds (JVM running for 8.913)
-2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
-2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
-2021-03-16 00:12:39.222  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms`,
           'id|+5': 101,
           'id|+5': 101,
           pipelineId: 100,
           pipelineId: 100,
           'result|1': ['成功', '失败', '执行中'],
           'result|1': ['成功', '失败', '执行中'],
@@ -63,12 +53,8 @@ router.get('/history/list', (req, res) => {
   ));
   ));
 });
 });
 
 
-router.get('/list', (req, res) => {
-  res.json(wrapper(
-    Mock.mock(
-      {
-        'data|10': [{
-          details: `2021-03-16 00:01:58.621  INFO 20584 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
+router.get('/history/details', (req, res) => {
+  res.json(wrapper(`2021-03-16 00:01:58.621  INFO 20584 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
 2021-03-16 00:01:58.622  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
 2021-03-16 00:01:58.622  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
 2021-03-16 00:01:58.634  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
 2021-03-16 00:01:58.634  INFO 20584 --- [           main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
 2021-03-16 00:01:58.641  INFO 20584 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
 2021-03-16 00:01:58.641  INFO 20584 --- [           main] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
@@ -77,7 +63,14 @@ router.get('/list', (req, res) => {
 2021-03-16 00:01:58.993  INFO 20584 --- [           main] s.devcloud.web.DevcloudWebApplication    : Started DevcloudWebApplication in 6.659 seconds (JVM running for 8.913)
 2021-03-16 00:01:58.993  INFO 20584 --- [           main] s.devcloud.web.DevcloudWebApplication    : Started DevcloudWebApplication in 6.659 seconds (JVM running for 8.913)
 2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
 2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
 2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
 2021-03-16 00:12:39.211  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
-2021-03-16 00:12:39.222  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms`,
+2021-03-16 00:12:39.222  INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms`));
+});
+
+router.get('/list', (req, res) => {
+  res.json(wrapper(
+    Mock.mock(
+      {
+        'data|10': [{
           'id|+1': 100,
           'id|+1': 100,
           name: Random.cname(),
           name: Random.cname(),
           'result|1': ['成功', '失败', '执行中'],
           'result|1': ['成功', '失败', '执行中'],

+ 10 - 1
src/api/devcloud/pipeline.ts

@@ -1,6 +1,6 @@
 import axios from '@/utils/axios';
 import axios from '@/utils/axios';
 
 
-import { PIPELINE_PREFIX, DEPLOYMENT_PREFIX } from './prefix';
+import { PIPELINE_PREFIX, DEPLOYMENT_PREFIX, STAGE_PREFIX } from './prefix';
 
 
 interface PipelinePayload {
 interface PipelinePayload {
   projectId: number;
   projectId: number;
@@ -32,6 +32,12 @@ export const updatePipeline = (updatePipelinePayload: UpdatePipelinePayload) =>
 
 
 export const getPipelineTemplates = () => axios.get(`${PIPELINE_PREFIX}/templates`);
 export const getPipelineTemplates = () => axios.get(`${PIPELINE_PREFIX}/templates`);
 
 
+export const getPipelineHistoryDetail = (historyId: number) => axios.get(`${PIPELINE_PREFIX}/history/details`, {
+  params: {
+    historyId,
+  },
+});
+
 export const getPipelineHistory = (pipeline: PipelinePayload) => axios.get(`${PIPELINE_PREFIX}/history/list`, {
 export const getPipelineHistory = (pipeline: PipelinePayload) => axios.get(`${PIPELINE_PREFIX}/history/list`, {
   params: pipeline,
   params: pipeline,
 });
 });
@@ -58,3 +64,6 @@ export const getDeploymentsByProjectId = (projectId: number) => axios.get(`${DEP
     projectId,
     projectId,
   },
   },
 });
 });
+
+// STAGE API
+export const getStages = () => axios.get(`${STAGE_PREFIX}`);

+ 1 - 0
src/api/devcloud/prefix.ts

@@ -6,3 +6,4 @@ export const PROJECT_PREFIX = '/project';
 export const GROUP_PREFIX = '/groups';
 export const GROUP_PREFIX = '/groups';
 export const BUGLIST_PREFIX = '/bug_list';
 export const BUGLIST_PREFIX = '/bug_list';
 export const APITEST_PREFIX = '/test';
 export const APITEST_PREFIX = '/test';
+export const STAGE_PREFIX = '/stages';

+ 10 - 10
src/views/Project/Pipeline.vue

@@ -1,7 +1,7 @@
 <template>
 <template>
   <ElTabs class="tabs" v-model="activeTab">
   <ElTabs class="tabs" v-model="activeTab">
     <ElTabPane label="流水线" name="pipeline">
     <ElTabPane label="流水线" name="pipeline">
-      <ElTable :data="pipelines" width="100%">
+      <ElTable :data="pipelines" width="100%" :default-sort="{prop: 'id', order: 'descending'}">
         <ElTableColumn
         <ElTableColumn
           prop="id"
           prop="id"
           label="ID"
           label="ID"
@@ -57,7 +57,7 @@
         >
         >
           <template #default="scope">
           <template #default="scope">
             <ElButton
             <ElButton
-              @click="handleClick('detail', scope.row.id)"
+              @click="handleClick('detail', scope.row.historyId)"
               type="text"
               type="text"
               size="small"
               size="small"
               :disabled="scope.row.result==='执行中'"
               :disabled="scope.row.result==='执行中'"
@@ -80,7 +80,7 @@
         </ElTableColumn>
         </ElTableColumn>
       </ElTable>
       </ElTable>
       <ElDialog v-model="showPipelineDetailModal" destroy-on-close>
       <ElDialog v-model="showPipelineDetailModal" destroy-on-close>
-        <template #title>最近一次流水线构建的执行结果详情</template>
+        <template #title>历史执行结果详情</template>
         <pre class="pipeline-detail">{{detail}}</pre>
         <pre class="pipeline-detail">{{detail}}</pre>
       </ElDialog>
       </ElDialog>
       <ElDialog v-model="showPipelineHistoryModal" destroy-on-close>
       <ElDialog v-model="showPipelineHistoryModal" destroy-on-close>
@@ -89,11 +89,6 @@
           :data="pipelineHistory"
           :data="pipelineHistory"
           height="400"
           height="400"
         >
         >
-          <ElTableColumn type="expand">
-            <template #default="scope">
-              <pre class="pipeline-detail">{{scope.row.details}}</pre>
-            </template>
-          </ElTableColumn>
           <ElTableColumn
           <ElTableColumn
             prop="id"
             prop="id"
             label="构建ID"
             label="构建ID"
@@ -117,6 +112,11 @@
             align="center"
             align="center"
             :formatter="(row) => formatter(row.startTime)"
             :formatter="(row) => formatter(row.startTime)"
           ></ElTableColumn>
           ></ElTableColumn>
+          <ElTableColumn>
+            <template #default="scope">
+              <ElButton @click="handleClick('detail', scope.row.id)" type="text" size="small">查看详情</ElButton>
+            </template>
+          </ElTableColumn>
         </ElTable>
         </ElTable>
       </ElDialog>
       </ElDialog>
       <ElDialog
       <ElDialog
@@ -189,7 +189,7 @@
       </ElDialog>
       </ElDialog>
     </ElTabPane>
     </ElTabPane>
     <ElTabPane label="部署产物" name="production">
     <ElTabPane label="部署产物" name="production">
-      <ElTable :data="productions" width="100%">
+      <ElTable :data="productions" width="100%" :default-sort="{prop: 'id', order: 'descending'}">
         <ElTableColumn
         <ElTableColumn
           prop="id"
           prop="id"
           label="ID"
           label="ID"
@@ -300,7 +300,7 @@ export default {
         }
         }
         case 'detail': {
         case 'detail': {
           this.showPipelineDetailModal = true;
           this.showPipelineDetailModal = true;
-          this.detail = Array.prototype.find.call(this.pipelines, (pipeline) => pipeline.id === id).details;
+          this.detail = await PipelineAPI.getPipelineHistoryDetail(id);
           break;
           break;
         }
         }
         case 'history': {
         case 'history': {