From bb2228e6631042bf69d7d47a9701533cd74a8150 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Wed, 15 Nov 2023 10:41:37 +0800 Subject: [PATCH] =?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 --- .../apigw/v3/ApigwBuildResourceV3Impl.kt | 7 +++--- .../apigw/v4/ApigwBuildResourceV4Impl.kt | 7 +++--- .../pojo/trigger/PipelineSpecificEvent.kt | 4 ++-- .../api/ServiceTriggerEventResourceImpl.kt | 2 +- .../process/api/UserBuildResourceImpl.kt | 7 +++--- .../service/PipelineRemoteAuthService.kt | 22 +++++++++++++++---- .../service/SubPipelineStartUpService.kt | 7 +++--- .../builds/PipelineBuildFacadeService.kt | 7 +++--- .../trigger/PipelineTriggerEventService.kt | 9 ++++---- .../i18n/process/message_en_US.properties | 2 +- .../i18n/process/message_zh_CN.properties | 2 +- 11 files changed, 48 insertions(+), 28 deletions(-) diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt index f2d10afaa97..468db0c092b 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwBuildResourceV3Impl.kt @@ -43,6 +43,7 @@ import com.tencent.devops.process.pojo.BuildManualStartupInfo import com.tencent.devops.process.pojo.BuildTaskPauseInfo import com.tencent.devops.process.pojo.pipeline.ModelDetail import com.tencent.devops.process.pojo.trigger.PipelineSpecificEvent +import com.tencent.devops.process.pojo.trigger.PipelineTriggerReason import com.tencent.devops.process.pojo.trigger.PipelineTriggerStatus import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -303,12 +304,12 @@ class ApigwBuildResourceV3Impl @Autowired constructor( ): BuildId { var buildId: BuildId? = null var status = PipelineTriggerStatus.SUCCEED.name - var failReason = "" + var reason: String = PipelineTriggerReason.TRIGGER_SUCCESS.name try { buildId = action.invoke() } catch (ignored: Exception) { status = PipelineTriggerStatus.FAILED.name - failReason = ignored.message.toString() + reason = ignored.message.toString() throw ignored } finally { try { @@ -321,7 +322,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor( eventSource = userId, triggerType = StartType.SERVICE.name, buildInfo = buildId, - failReason = failReason, + reason = reason, status = status ) ) diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt index 4256d842713..065d23fc4cd 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt @@ -51,6 +51,7 @@ import com.tencent.devops.process.pojo.BuildTaskPauseInfo import com.tencent.devops.process.pojo.ReviewParam import com.tencent.devops.process.pojo.pipeline.ModelRecord import com.tencent.devops.process.pojo.trigger.PipelineSpecificEvent +import com.tencent.devops.process.pojo.trigger.PipelineTriggerReason import com.tencent.devops.process.pojo.trigger.PipelineTriggerStatus import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -449,12 +450,12 @@ class ApigwBuildResourceV4Impl @Autowired constructor( ): BuildId { var buildId: BuildId? = null var status = PipelineTriggerStatus.SUCCEED.name - var failReason = "" + var reason: String = PipelineTriggerReason.TRIGGER_SUCCESS.name try { buildId = action.invoke() } catch (ignored: Exception) { status = PipelineTriggerStatus.FAILED.name - failReason = ignored.message.toString() + reason = ignored.message.toString() throw ignored } finally { try { @@ -467,7 +468,7 @@ class ApigwBuildResourceV4Impl @Autowired constructor( eventSource = userId, triggerType = StartType.SERVICE.name, buildInfo = buildId, - failReason = failReason, + reason = reason, status = status ) ) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/trigger/PipelineSpecificEvent.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/trigger/PipelineSpecificEvent.kt index 2ebb505fa7d..2e7d03ba7e6 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/trigger/PipelineSpecificEvent.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/trigger/PipelineSpecificEvent.kt @@ -51,6 +51,6 @@ data class PipelineSpecificEvent( val buildInfo: BuildId?, @ApiModelProperty("构建状态") val status: String, - @ApiModelProperty("失败信息") - val failReason: String + @ApiModelProperty("原因") + val reason: String ) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceTriggerEventResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceTriggerEventResourceImpl.kt index 311af05ae41..12e3fde972b 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceTriggerEventResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceTriggerEventResourceImpl.kt @@ -50,7 +50,7 @@ class ServiceTriggerEventResourceImpl @Autowired constructor( triggerType = triggerType, buildInfo = buildInfo, status = status, - failReason = failReason + reason = reason ) } return true diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt index 9cfab62c9af..4e95ba4a311 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt @@ -49,6 +49,7 @@ import com.tencent.devops.process.pojo.ReviewParam import com.tencent.devops.process.pojo.pipeline.ModelDetail import com.tencent.devops.process.pojo.pipeline.ModelRecord import com.tencent.devops.process.pojo.trigger.PipelineSpecificEvent +import com.tencent.devops.process.pojo.trigger.PipelineTriggerReason import com.tencent.devops.process.pojo.trigger.PipelineTriggerStatus import com.tencent.devops.process.service.PipelineRecentUseService import com.tencent.devops.process.service.builds.PipelineBuildFacadeService @@ -559,12 +560,12 @@ class UserBuildResourceImpl @Autowired constructor( ): BuildId { var buildId: BuildId? = null var status = PipelineTriggerStatus.SUCCEED.name - var failReason = "" + var reason: String = PipelineTriggerReason.TRIGGER_SUCCESS.name try { buildId = action.invoke() } catch (ignored: Exception) { status = PipelineTriggerStatus.FAILED.name - failReason = ignored.message.toString() + reason = ignored.message.toString() throw ignored } finally { try { @@ -577,7 +578,7 @@ class UserBuildResourceImpl @Autowired constructor( eventSource = userId, triggerType = StartType.MANUAL.name, buildInfo = buildId, - failReason = failReason, + reason = reason, status = status ) ) 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 ed75ba6e469..be224086dbe 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 @@ -28,6 +28,8 @@ package com.tencent.devops.process.service import com.tencent.devops.common.api.exception.OperationException +import com.tencent.devops.common.api.pojo.I18Variable +import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.common.api.util.MessageUtil import com.tencent.devops.common.api.util.UUIDUtil import com.tencent.devops.common.client.Client @@ -38,6 +40,7 @@ import com.tencent.devops.common.pipeline.enums.StartType import com.tencent.devops.common.redis.RedisOperation import com.tencent.devops.common.service.BkTag import com.tencent.devops.common.web.utils.I18nUtil +import com.tencent.devops.common.webhook.enums.WebhookI18nConstants import com.tencent.devops.model.process.tables.records.TPipelineRemoteAuthRecord import com.tencent.devops.process.api.service.ServiceBuildResource import com.tencent.devops.process.api.service.ServiceTriggerEventResource @@ -50,6 +53,7 @@ import com.tencent.devops.process.engine.service.PipelineRepositoryService import com.tencent.devops.process.pojo.BuildId import com.tencent.devops.process.pojo.PipelineRemoteToken import com.tencent.devops.process.pojo.trigger.PipelineSpecificEvent +import com.tencent.devops.process.pojo.trigger.PipelineTriggerReason import com.tencent.devops.process.pojo.trigger.PipelineTriggerStatus import com.tencent.devops.process.service.builds.PipelineBuildFacadeService import com.tencent.devops.process.utils.PIPELINE_START_REMOTE_USER_ID @@ -187,12 +191,12 @@ class PipelineRemoteAuthService @Autowired constructor( ): BuildId { var buildId: BuildId? = null var status = PipelineTriggerStatus.SUCCEED.name - var failReason = "" + var reason: String = PipelineTriggerReason.TRIGGER_SUCCESS.name try { buildId = action.invoke() } catch (ignored: Exception) { status = PipelineTriggerStatus.FAILED.name - failReason = ignored.message.toString() + reason = ignored.message.toString() throw ignored } finally { try { @@ -205,8 +209,18 @@ class PipelineRemoteAuthService @Autowired constructor( eventSource = eventSource, triggerType = StartType.REMOTE.name, buildInfo = buildId, - failReason = failReason, - status = status + reason = reason, + status = status, + eventDesc = JsonUtil.toJson( + I18Variable( + code = WebhookI18nConstants.REMOTE_START_EVENT_DESC, + params = listOf( + userId, + eventSource + ) + ), + false + ) ) ) } catch (ignored: Exception) { diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt index aa20e2ee1e8..7246305152e 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt @@ -61,6 +61,7 @@ import com.tencent.devops.process.pojo.pipeline.StartUpInfo import com.tencent.devops.process.pojo.pipeline.SubPipelineStartUpInfo import com.tencent.devops.process.pojo.pipeline.SubPipelineStatus import com.tencent.devops.process.pojo.trigger.PipelineSpecificEvent +import com.tencent.devops.process.pojo.trigger.PipelineTriggerReason import com.tencent.devops.process.pojo.trigger.PipelineTriggerStatus import com.tencent.devops.process.service.builds.PipelineBuildFacadeService import com.tencent.devops.process.service.pipeline.PipelineBuildService @@ -520,12 +521,12 @@ class SubPipelineStartUpService @Autowired constructor( ): BuildId { var buildId: BuildId? = null var status = PipelineTriggerStatus.SUCCEED.name - var failReason = "" + var reason: String = PipelineTriggerReason.TRIGGER_SUCCESS.name try { buildId = action.invoke() } catch (ignored: Exception) { status = PipelineTriggerStatus.FAILED.name - failReason = ignored.message.toString() + reason = ignored.message.toString() throw ignored } finally { try { @@ -549,7 +550,7 @@ class SubPipelineStartUpService @Autowired constructor( ), false ), - failReason = failReason, + reason = reason, status = status ) ) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 35716238cc8..2fc2db4bcad 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -116,6 +116,7 @@ import com.tencent.devops.process.pojo.pipeline.ModelDetail import com.tencent.devops.process.pojo.pipeline.ModelRecord import com.tencent.devops.process.pojo.pipeline.PipelineLatestBuild import com.tencent.devops.process.pojo.trigger.PipelineSpecificEvent +import com.tencent.devops.process.pojo.trigger.PipelineTriggerReason import com.tencent.devops.process.pojo.trigger.PipelineTriggerStatus import com.tencent.devops.process.service.BuildVariableService import com.tencent.devops.process.service.ParamFacadeService @@ -2511,12 +2512,12 @@ class PipelineBuildFacadeService( ): BuildId { var buildId: BuildId? = null var status = PipelineTriggerStatus.SUCCEED.name - var failReason = "" + var reason: String = PipelineTriggerReason.TRIGGER_SUCCESS.name try { buildId = action.invoke() } catch (ignored: Exception) { status = PipelineTriggerStatus.FAILED.name - failReason = ignored.message.toString() + reason = ignored.message.toString() throw ignored } finally { try { @@ -2529,7 +2530,7 @@ class PipelineBuildFacadeService( eventSource = userId, triggerType = StartType.TIME_TRIGGER.name, buildInfo = buildId, - failReason = failReason, + reason = reason, status = status ) ) 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 3ffe5048f21..34466d4dd59 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 @@ -415,7 +415,7 @@ class PipelineTriggerEventService @Autowired constructor( triggerType: String = PipelineTriggerType.MANUAL.name, buildInfo: BuildId?, status: String = PipelineTriggerStatus.SUCCEED.name, - failReason: String? = null + reason: String? = null ) { logger.info("start save specific event|$projectId|$pipelineId|$userId|$triggerType") val pipelineInfo = client.get(ServicePipelineResource::class).getPipelineInfo( @@ -435,7 +435,7 @@ class PipelineTriggerEventService @Autowired constructor( userId = userId, buildNum = buildInfo?.num.toString(), triggerType = triggerType, - failReason = failReason + reason = reason ) } @@ -454,7 +454,7 @@ class PipelineTriggerEventService @Autowired constructor( triggerType: String, requestParams: Map?, eventDesc: String? = null, - failReason: String? + reason: String? ) { val eventId = getEventId() val requestId = MDC.get(TraceTag.BIZID) @@ -479,7 +479,7 @@ class PipelineTriggerEventService @Autowired constructor( buildId = buildId, buildNum = buildNum, pipelineName = pipelineName, - reason = failReason + reason = reason ), triggerEvent = PipelineTriggerEvent( eventId = eventId, @@ -501,6 +501,7 @@ class PipelineTriggerEventService @Autowired constructor( PipelineTriggerType.REMOTE.name -> WebhookI18nConstants.REMOTE_START_EVENT_DESC PipelineTriggerType.SERVICE.name -> WebhookI18nConstants.SERVICE_START_EVENT_DESC PipelineTriggerType.PIPELINE.name -> WebhookI18nConstants.PIPELINE_START_EVENT_DESC + PipelineTriggerType.TIME_TRIGGER.name -> WebhookI18nConstants.TIMING_START_EVENT_DESC else -> "" } diff --git a/support-files/i18n/process/message_en_US.properties b/support-files/i18n/process/message_en_US.properties index 7a5118afca4..25ccdf85b6e 100644 --- a/support-files/i18n/process/message_en_US.properties +++ b/support-files/i18n/process/message_en_US.properties @@ -384,7 +384,7 @@ bkGithubPrEventDesc=Pull request [!{1}] by {1} {2} bkSvnCommitEventDesc=Commit [{0}] pushed by {1} bkManualStartEventDesc=Manually triggered by {0} -bkRemoteStartEventDesc=Remote api triggered by {0} +bkRemoteStartEventDesc=Remote api triggered by {1} [{0}] bkServiceStartEventDesc=Pipeline invocation triggered by {0} invoke bkPipelinetartEventDesc=Pipeline invocation [{2}] triggered by {0} invoke bkTimingStartEventDesc=Timer triggered by {0} diff --git a/support-files/i18n/process/message_zh_CN.properties b/support-files/i18n/process/message_zh_CN.properties index 83e5a933a07..a53ecd4ad25 100644 --- a/support-files/i18n/process/message_zh_CN.properties +++ b/support-files/i18n/process/message_zh_CN.properties @@ -384,7 +384,7 @@ bkGithubPrEventDesc=Pull request [{1}] 由 {1} {2} bkSvnCommitEventDesc=提交 [{0}] 由 {1} 推送 bkManualStartEventDesc={0} 手动触发 -bkRemoteStartEventDesc={0} 远程触发 +bkRemoteStartEventDesc={1} [{0}] 远程触发 bkServiceStartEventDesc={0} 触发的流水线调用 bkPipelinetartEventDesc={0} 触发的流水线 [{2}] 调用 bkTimingStartEventDesc={0} 定时触发