From e4f1a68c9aaf68b97053b1f3b5150400dc9a81f6 Mon Sep 17 00:00:00 2001 From: v_hwweng Date: Mon, 30 Dec 2024 14:55:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232=20#=20Reviewed,=20transaction=20id:=2028105?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PipelineHeader/DetailHeader.vue | 178 +++++++++++++++--- .../src/store/modules/pipelines/build.js | 8 + src/frontend/locale/pipeline/en-US.json | 11 +- src/frontend/locale/pipeline/zh-CN.json | 11 +- 4 files changed, 179 insertions(+), 29 deletions(-) diff --git a/src/frontend/devops-pipeline/src/components/PipelineHeader/DetailHeader.vue b/src/frontend/devops-pipeline/src/components/PipelineHeader/DetailHeader.vue index dc647564cc63..cb8b70144964 100644 --- a/src/frontend/devops-pipeline/src/components/PipelineHeader/DetailHeader.vue +++ b/src/frontend/devops-pipeline/src/components/PipelineHeader/DetailHeader.vue @@ -19,29 +19,88 @@ :icon="loading ? 'loading' : ''" outline theme="warning" - @click="handleClick" + @click="handleCancel" > {{ $t("cancel") }} { + try { + this.loading = true + await this.retry(type, this.execDetail?.id) + return true + } catch (err) { + this.handleError(err, { + projectId: this.$route.params.projectId, + resourceCode: this.$route.params.pipelineId, + action: this.$permissionResourceAction.EXECUTE + }) + this.loading = false + } + } + }) + }, + async retry (type = 'reBuild', buildId, goDetail = false) { const { projectId, pipelineId } = this.$route.params - + const retryFn = type === 'reBuild' ? this.requestRetryPipeline : this.requestRePlayPipeline // 请求执行构建 - const res = await this.requestRetryPipeline({ + const res = await retryFn({ ...this.$route.params, buildId }) @@ -277,5 +353,53 @@ padding-right: 24px; } } + .rebuild-dropdown-trigger { + display: flex; + align-items: center; + justify-content: center; + border: 1px solid #c4c6cc; + height: 32px; + font-size: 14px; + border-radius: 2px; + padding: 0 15px; + color: #63656E; + &:hover { + cursor: pointer; + border-color: #979ba5; + } + .icon-angle-down { + margin-left: 5px; + font-size: 16px; + } + .spin-icon { + margin-right: 5px; + color: #458bff; + z-index: 2000; + } + } + .rebuild-dropdown-content { + .dropdown-item { + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + height: 32px; + line-height: 32px; + font-size: 14px; + + &:hover { + background-color: #f0f1f5; + color: #3a84ff; + } + &.disabled { + cursor: not-allowed; + color: #dcdee5; + } + .icon-info-circle { + margin-left: 5px; + font-size: 12px; + } + } + } } diff --git a/src/frontend/devops-pipeline/src/store/modules/pipelines/build.js b/src/frontend/devops-pipeline/src/store/modules/pipelines/build.js index 5f58cc362781..c3355429cd5a 100755 --- a/src/frontend/devops-pipeline/src/store/modules/pipelines/build.js +++ b/src/frontend/devops-pipeline/src/store/modules/pipelines/build.js @@ -291,6 +291,14 @@ const actions = { return ajax.get(`artifactory/api/user/artifactories/${projectId}/${artifactoryType}/show?path=${path}`).then(response => { return response.data }) + }, + /** + * 重放流水线 + */ + requestRePlayPipeline ({ commit, state, dispatch }, { projectId, pipelineId, buildId }) { + return ajax.post(`${prefix}${projectId}/${pipelineId}/${buildId}/replayByBuild`).then(response => { + return response.data + }) } } diff --git a/src/frontend/locale/pipeline/en-US.json b/src/frontend/locale/pipeline/en-US.json index 2b6e63e533f8..d9ad5633d54a 100644 --- a/src/frontend/locale/pipeline/en-US.json +++ b/src/frontend/locale/pipeline/en-US.json @@ -620,7 +620,16 @@ "copyToCustomArtifactory": "Copy to custom artifactory", "downloading": "Downloading ", "copySuc": " Copy {0} to custom artifactory successfully", - "buildMsg": "Build Message" + "buildMsg": "Build Message", + "replay": "Re-play", + "reBuildTips1": "When rebuilding, the execution will be queried with the same trigger parameters, and:", + "reBuildTips2": "- The build ID remains unchanged", + "reBuildTips3": "- The pipeline version used is based on the initial trigger", + "rePlayTips1": "After replaying, a new build will be initiated with the same trigger parameters:", + "rePlayTips2": "- A new build ID will be generated", + "rePlayTips3": "- The latest pipeline version will be used to run", + "reBuildConfirmTips": "Are you sure you want to initiate a rebuild?", + "rePlayConfirmTips": "Are you sure you want to replay the event for this pipeline?" }, "preview": { "build": "Build", diff --git a/src/frontend/locale/pipeline/zh-CN.json b/src/frontend/locale/pipeline/zh-CN.json index e4c370eb1c6f..280fc5f8b778 100644 --- a/src/frontend/locale/pipeline/zh-CN.json +++ b/src/frontend/locale/pipeline/zh-CN.json @@ -615,7 +615,16 @@ "copyToCustomArtifactory": "复制至自定义仓库", "downloading": "正在下载", "copySuc": "复制{0}至自定义仓库成功", - "buildMsg": "构建信息" + "buildMsg": "构建信息", + "rePlay": "重放事件", + "reBuildTips1": "重新构建时,将以同样的触发参数查询执行,且:", + "reBuildTips2": "- build id 不变", + "reBuildTips3": "- 使用的流水线版本以首次触发为准", + "rePlayTips1": "重放后,将以同样的触发参数启动一次新的构建:", + "rePlayTips2": "- 生成新的 build id", + "rePlayTips3": "- 使用最新的流水线版本运行", + "reBuildConfirmTips": "确定发起重新构建吗?", + "rePlayConfirmTips": "确定针对此流水线重放事件吗?" }, "preview": { "build": "构建", From 3177bc1d1f6dd752b1b7a3bc92cb81a85c9d2a19 Mon Sep 17 00:00:00 2001 From: v_hwweng Date: Thu, 2 Jan 2025 11:32:35 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/locale/pipeline/en-US.json | 2 +- src/frontend/locale/pipeline/zh-CN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/locale/pipeline/en-US.json b/src/frontend/locale/pipeline/en-US.json index d9ad5633d54a..285e3cd249f4 100644 --- a/src/frontend/locale/pipeline/en-US.json +++ b/src/frontend/locale/pipeline/en-US.json @@ -622,7 +622,7 @@ "copySuc": " Copy {0} to custom artifactory successfully", "buildMsg": "Build Message", "replay": "Re-play", - "reBuildTips1": "When rebuilding, the execution will be queried with the same trigger parameters, and:", + "reBuildTips1": "When rebuilding, it will be re-executed with the same trigger parameters, and:", "reBuildTips2": "- The build ID remains unchanged", "reBuildTips3": "- The pipeline version used is based on the initial trigger", "rePlayTips1": "After replaying, a new build will be initiated with the same trigger parameters:", diff --git a/src/frontend/locale/pipeline/zh-CN.json b/src/frontend/locale/pipeline/zh-CN.json index 280fc5f8b778..2012c20a3a7b 100644 --- a/src/frontend/locale/pipeline/zh-CN.json +++ b/src/frontend/locale/pipeline/zh-CN.json @@ -617,7 +617,7 @@ "copySuc": "复制{0}至自定义仓库成功", "buildMsg": "构建信息", "rePlay": "重放事件", - "reBuildTips1": "重新构建时,将以同样的触发参数查询执行,且:", + "reBuildTips1": "重新构建时,将以同样的触发参数重新执行,且:", "reBuildTips2": "- build id 不变", "reBuildTips3": "- 使用的流水线版本以首次触发为准", "rePlayTips1": "重放后,将以同样的触发参数启动一次新的构建:", From 601f74431a835c852db00703585f51633825d42b Mon Sep 17 00:00:00 2001 From: v_hwweng Date: Mon, 13 Jan 2025 15:46:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232=20#=20Reviewed,=20transaction=20id:=2029093?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PipelineHeader/DetailHeader.vue | 46 +++++++++++++++++-- .../src/store/modules/pipelines/build.js | 6 ++- src/frontend/locale/pipeline/en-US.json | 10 ++-- src/frontend/locale/pipeline/zh-CN.json | 10 ++-- 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/frontend/devops-pipeline/src/components/PipelineHeader/DetailHeader.vue b/src/frontend/devops-pipeline/src/components/PipelineHeader/DetailHeader.vue index cb8b70144964..54d239b3bd3f 100644 --- a/src/frontend/devops-pipeline/src/components/PipelineHeader/DetailHeader.vue +++ b/src/frontend/devops-pipeline/src/components/PipelineHeader/DetailHeader.vue @@ -238,10 +238,28 @@ } }, async handleClick (type = 'reBuild') { + const h = this.$createElement const title = type === 'reBuild' ? this.$t('history.reBuildConfirmTips') : this.$t('history.rePlayConfirmTips') this.$bkInfo({ title, + width: 500, confirmLoading: true, + subHeader: h('div', { + style: { + background: '#f5f6fa', + padding: '10px', + fontSize: '12px', + lineHeight: '20px' + } + }, type === 'reBuild' + ? [ + h('p', this.$t('history.reBuildInfo1')), + h('p', this.$t('history.reBuildInfo2')) + ] + : [ + h('p', this.$t('history.rePlayInfo1')), + h('p', this.$t('history.rePlayInfo2')) + ]), confirmFn: async () => { try { this.loading = true @@ -258,15 +276,15 @@ } }) }, - async retry (type = 'reBuild', buildId, goDetail = false) { + async retry (type = 'reBuild', buildId, forceTrigger = false) { const { projectId, pipelineId } = this.$route.params const retryFn = type === 'reBuild' ? this.requestRetryPipeline : this.requestRePlayPipeline // 请求执行构建 const res = await retryFn({ ...this.$route.params, - buildId + buildId, + forceTrigger }) - if (res && res.id) { this.$router.replace({ name: 'pipelinesDetail', @@ -284,6 +302,28 @@ message: this.$t('subpage.rebuildSuc'), theme: 'success' }) + } else if (res.code === 2101260) { + this.loading = false + this.$bkInfo({ + title: this.$t('history.rePlay'), + subTitle: res.message, + width: 500, + confirmLoading: true, + confirmFn: async () => { + try { + this.loading = true + await this.retry('rePlay', buildId, true) + return true + } catch (err) { + this.handleError(err, { + projectId: this.$route.params.projectId, + resourceCode: this.$route.params.pipelineId, + action: this.$permissionResourceAction.EXECUTE + }) + this.loading = false + } + } + }) } else { throw Error(this.$t('subpage.rebuildFail')) } diff --git a/src/frontend/devops-pipeline/src/store/modules/pipelines/build.js b/src/frontend/devops-pipeline/src/store/modules/pipelines/build.js index c3355429cd5a..69f43d993280 100755 --- a/src/frontend/devops-pipeline/src/store/modules/pipelines/build.js +++ b/src/frontend/devops-pipeline/src/store/modules/pipelines/build.js @@ -295,9 +295,11 @@ const actions = { /** * 重放流水线 */ - requestRePlayPipeline ({ commit, state, dispatch }, { projectId, pipelineId, buildId }) { - return ajax.post(`${prefix}${projectId}/${pipelineId}/${buildId}/replayByBuild`).then(response => { + requestRePlayPipeline ({ commit, state, dispatch }, { projectId, pipelineId, buildId, forceTrigger = false }) { + return ajax.post(`${prefix}${projectId}/${pipelineId}/${buildId}/replayByBuild?forceTrigger=${forceTrigger}`).then(response => { return response.data + }).catch(e => { + return e }) } } diff --git a/src/frontend/locale/pipeline/en-US.json b/src/frontend/locale/pipeline/en-US.json index 285e3cd249f4..a8d69d5c3bdf 100644 --- a/src/frontend/locale/pipeline/en-US.json +++ b/src/frontend/locale/pipeline/en-US.json @@ -623,13 +623,17 @@ "buildMsg": "Build Message", "replay": "Re-play", "reBuildTips1": "When rebuilding, it will be re-executed with the same trigger parameters, and:", - "reBuildTips2": "- The build ID remains unchanged", + "reBuildTips2": "- The BK_CI_BUILD_NO remains unchanged", "reBuildTips3": "- The pipeline version used is based on the initial trigger", "rePlayTips1": "After replaying, a new build will be initiated with the same trigger parameters:", - "rePlayTips2": "- A new build ID will be generated", + "rePlayTips2": "- A new BK_CI_BUILD_NO will be generated", "rePlayTips3": "- The latest pipeline version will be used to run", "reBuildConfirmTips": "Are you sure you want to initiate a rebuild?", - "rePlayConfirmTips": "Are you sure you want to replay the event for this pipeline?" + "rePlayConfirmTips": "Are you sure you want to replay the event for this pipeline?", + "rePlayInfo1": "1. When replaying, start a new Play with the same trigger parameters and the latest pipeline version.", + "rePlayInfo2": "2. When replaying, skip trigger detection, and it may not meet the trigger conditions of the latest version.", + "reBuildInfo1": "1. Rebuilding is to re-execute on the basis of the previous build.", + "reBuildInfo2": "2. Pipeline version, BK_CI_BUILD_ID are consistent with those when it is triggered for the first time." }, "preview": { "build": "Build", diff --git a/src/frontend/locale/pipeline/zh-CN.json b/src/frontend/locale/pipeline/zh-CN.json index 2012c20a3a7b..d406523a7078 100644 --- a/src/frontend/locale/pipeline/zh-CN.json +++ b/src/frontend/locale/pipeline/zh-CN.json @@ -618,13 +618,17 @@ "buildMsg": "构建信息", "rePlay": "重放事件", "reBuildTips1": "重新构建时,将以同样的触发参数重新执行,且:", - "reBuildTips2": "- build id 不变", + "reBuildTips2": "- BK_CI_BUILD_NO 不变", "reBuildTips3": "- 使用的流水线版本以首次触发为准", "rePlayTips1": "重放后,将以同样的触发参数启动一次新的构建:", - "rePlayTips2": "- 生成新的 build id", + "rePlayTips2": "- 生成新的 BK_CI_BUILD_NO", "rePlayTips3": "- 使用最新的流水线版本运行", "reBuildConfirmTips": "确定发起重新构建吗?", - "rePlayConfirmTips": "确定针对此流水线重放事件吗?" + "rePlayConfirmTips": "确定针对此流水线重放事件吗?", + "rePlayInfo1": "1. 重放时,以相同的触发参数、最新的流水线编排启动一次新的构建", + "rePlayInfo2": "2. 重放时,跳过触发器检测,有可能不满足最新版本的触发条件", + "reBuildInfo1": "1. 重新构建,是在之前的构建基础上重新执行", + "reBuildInfo2": "2. 流水线编排版本、BK_CI_BUILD_ID和首次触发时一致" }, "preview": { "build": "构建", From 410628a5efd3d3a2e40ede0684ad8e50e8eb9380 Mon Sep 17 00:00:00 2001 From: v_hwweng Date: Mon, 13 Jan 2025 17:30:57 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=9E=84=E5=BB=BA=E9=87=8D=E6=94=BE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=20#11232?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/locale/pipeline/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/locale/pipeline/en-US.json b/src/frontend/locale/pipeline/en-US.json index a8d69d5c3bdf..aaa8fe560789 100644 --- a/src/frontend/locale/pipeline/en-US.json +++ b/src/frontend/locale/pipeline/en-US.json @@ -621,7 +621,7 @@ "downloading": "Downloading ", "copySuc": " Copy {0} to custom artifactory successfully", "buildMsg": "Build Message", - "replay": "Re-play", + "rePlay": "Re-play", "reBuildTips1": "When rebuilding, it will be re-executed with the same trigger parameters, and:", "reBuildTips2": "- The BK_CI_BUILD_NO remains unchanged", "reBuildTips3": "- The pipeline version used is based on the initial trigger",