From b5acd8c9164dc858d4760ec08cb41e7f687553e7 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 27 Oct 2023 09:08:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4=E5=BA=A6?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/tencent/devops/common/api/pojo/I18Variable.kt | 2 +- .../devops/process/service/PipelineRemoteAuthService.kt | 3 ++- .../devops/process/webhook/listener/WebhookEventListener.kt | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/pojo/I18Variable.kt b/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/pojo/I18Variable.kt index 2af7d8e2c08..687bb6ea39d 100644 --- a/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/pojo/I18Variable.kt +++ b/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/pojo/I18Variable.kt @@ -42,4 +42,4 @@ data class I18Variable( val defaultMessage: String? = null ) { fun toJsonStr() = JsonUtil.toJson(this, false) -} \ No newline at end of file +} diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineRemoteAuthService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineRemoteAuthService.kt index f2cea5b1a4b..cb2efe6f4ed 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineRemoteAuthService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/PipelineRemoteAuthService.kt @@ -129,7 +129,8 @@ class PipelineRemoteAuthService @Autowired constructor( 不使用client.get直接调用,因client内不支持同服务间的feign调用。故只能通过网关代理下 */ val projectConsulTag = redisOperation.hget(ConsulConstants.PROJECT_TAG_REDIS_KEY, pipeline.projectId) return bkTag.invokeByTag(projectConsulTag) { - logger.info("start call service api ${pipeline.projectId} ${pipeline.pipelineId}, $projectConsulTag ${bkTag.getFinalTag()}") + logger.info("start call service api ${pipeline.projectId} ${pipeline.pipelineId}, " + + "$projectConsulTag ${bkTag.getFinalTag()}") val buildId = pipelineTriggerEventService.saveSpecificEvent( projectId = pipeline.projectId, pipelineId = pipeline.pipelineId, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/listener/WebhookEventListener.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/listener/WebhookEventListener.kt index a07298e70c0..fd01dcf9eb7 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/listener/WebhookEventListener.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/listener/WebhookEventListener.kt @@ -52,6 +52,7 @@ class WebhookEventListener constructor( private val webhookRequestService: WebhookRequestService ) { + @SuppressWarnings("ComplexMethod", "LongMethod") fun handleCommitEvent(event: ICodeWebhookEvent) { val traceId = MDC.get(TraceTag.BIZID) if (traceId.isNullOrEmpty()) { From 6a76e6b1b56127d6211367c584f10e1f0660ea50 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 27 Oct 2023 10:04:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4=E5=BA=A6?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/trigger/PipelineTriggerEventVo.kt | 6 ++- .../trigger/PipelineTriggerEventService.kt | 45 ++++++++++++------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/trigger/PipelineTriggerEventVo.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/trigger/PipelineTriggerEventVo.kt index 90f6e98391e..edefbcdb43c 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/trigger/PipelineTriggerEventVo.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/trigger/PipelineTriggerEventVo.kt @@ -61,6 +61,8 @@ data class PipelineTriggerEventVo( var buildNum: String? = null, @ApiModelProperty("原因") var reason: String? = null, - @ApiModelProperty("原因详情", required = false) - var reasonDetailList: List? = null + @ApiModelProperty("失败原因详情", required = false) + var reasonDetailList: List? = null, + @ApiModelProperty("失败原因", required = false) + var failReason: String = "" ) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt index c1b3f462e4c..b55ee1cb097 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt @@ -123,6 +123,7 @@ class PipelineTriggerEventService @Autowired constructor( val pageNotNull = page ?: 0 val pageSizeNotNull = pageSize ?: PageUtil.MAX_PAGE_SIZE val sqlLimit = PageUtil.convertPageSizeToSQLMAXLimit(pageNotNull, pageSizeNotNull) + val language = I18nUtil.getLanguage(userId) val count = pipelineTriggerEventDao.countTriggerEvent( dslContext = dslContext, projectId = projectId, @@ -145,13 +146,7 @@ class PipelineTriggerEventService @Autowired constructor( limit = sqlLimit.limit, offset = sqlLimit.offset ).map { - it.eventDesc = try { - JsonUtil.to(it.eventDesc, I18Variable::class.java).getCodeLanMessage(I18nUtil.getLanguage(userId)) - } catch (ignored: Exception) { - logger.warn("Failed to resolve repo trigger event|sourceDesc[${it.eventDesc}]", ignored) - it.eventDesc - } - it + fillEventDetailParam(it, language) } return SQLPage(count = count, records = records) } @@ -239,11 +234,7 @@ class PipelineTriggerEventService @Autowired constructor( limit = sqlLimit.limit, offset = sqlLimit.offset ).map { - it.eventDesc = it.getI18nEventDesc(language) - it.buildNum = it.getBuildNumUrl() - it.reasonDetailList = it.getI18nReasonDetailDesc(language) - it.reason = it.getI18nReason(language) - it + fillEventDetailParam(it, language) } val count = pipelineTriggerEventDao.countTriggerEvent( dslContext = dslContext, @@ -434,14 +425,14 @@ class PipelineTriggerEventService @Autowired constructor( listOf() } - private fun PipelineTriggerEventVo.getI18nReason(language: String): String = getCodeLanMessage( - messageCode = if (this.reason.isNullOrBlank()) { + private fun getI18nReason(reason: String?, language: String): String = getCodeLanMessage( + messageCode = if (reason.isNullOrBlank()) { PipelineTriggerReason.TRIGGER_SUCCESS.name } else { - this.reason!! + reason }, language = language, - defaultMessage = this.reason + defaultMessage = reason ) /** @@ -456,4 +447,26 @@ class PipelineTriggerEventService @Autowired constructor( null } } + + /** + * 填充事件相关参数 + * 事件描述国际化,构建链接,失败详情国际化,触发状态国际化,失败状态国际化 + */ + private fun fillEventDetailParam( + eventParam: PipelineTriggerEventVo, + language: String + ): PipelineTriggerEventVo { + return with(eventParam) { + eventDesc = getI18nEventDesc(language) + buildNum = getBuildNumUrl() + reasonDetailList = getI18nReasonDetailDesc(language) + reason = getI18nReason(eventParam.reason, language) + failReason = if (!reasonDetailList.isNullOrEmpty()) { + getI18nReason(PipelineTriggerReason.TRIGGER_NOT_MATCH.name, language) + } else { + "" + } + this + } + } } From 6714f72e63ce97279e4526b23c3b568280ba5274 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 27 Oct 2023 10:49:44 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4=E5=BA=A6?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/trigger/PipelineTriggerEventService.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt index b55ee1cb097..a8568129f47 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/trigger/PipelineTriggerEventService.kt @@ -146,7 +146,9 @@ class PipelineTriggerEventService @Autowired constructor( limit = sqlLimit.limit, offset = sqlLimit.offset ).map { - fillEventDetailParam(it, language) + it.eventDesc = it.getI18nEventDesc(language) + it.reason = getI18nReason(it.reason,language) + it } return SQLPage(count = count, records = records) }