Skip to content

Commit

Permalink
【PAC】feat:支持从代码库维度查看对应的代码库事件 #8122
Browse files Browse the repository at this point in the history
  • Loading branch information
hejieehe committed Nov 15, 2023
1 parent 06b4641 commit bb2228e
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -321,7 +322,7 @@ class ApigwBuildResourceV3Impl @Autowired constructor(
eventSource = userId,
triggerType = StartType.SERVICE.name,
buildInfo = buildId,
failReason = failReason,
reason = reason,
status = status
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -467,7 +468,7 @@ class ApigwBuildResourceV4Impl @Autowired constructor(
eventSource = userId,
triggerType = StartType.SERVICE.name,
buildInfo = buildId,
failReason = failReason,
reason = reason,
status = status
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ data class PipelineSpecificEvent(
val buildInfo: BuildId?,
@ApiModelProperty("构建状态")
val status: String,
@ApiModelProperty("失败信息")
val failReason: String
@ApiModelProperty("原因")
val reason: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ServiceTriggerEventResourceImpl @Autowired constructor(
triggerType = triggerType,
buildInfo = buildInfo,
status = status,
failReason = failReason
reason = reason
)
}
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -577,7 +578,7 @@ class UserBuildResourceImpl @Autowired constructor(
eventSource = userId,
triggerType = StartType.MANUAL.name,
buildInfo = buildId,
failReason = failReason,
reason = reason,
status = status
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -549,7 +550,7 @@ class SubPipelineStartUpService @Autowired constructor(
),
false
),
failReason = failReason,
reason = reason,
status = status
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -2529,7 +2530,7 @@ class PipelineBuildFacadeService(
eventSource = userId,
triggerType = StartType.TIME_TRIGGER.name,
buildInfo = buildId,
failReason = failReason,
reason = reason,
status = status
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -435,7 +435,7 @@ class PipelineTriggerEventService @Autowired constructor(
userId = userId,
buildNum = buildInfo?.num.toString(),
triggerType = triggerType,
failReason = failReason
reason = reason
)
}

Expand All @@ -454,7 +454,7 @@ class PipelineTriggerEventService @Autowired constructor(
triggerType: String,
requestParams: Map<String, String>?,
eventDesc: String? = null,
failReason: String?
reason: String?
) {
val eventId = getEventId()
val requestId = MDC.get(TraceTag.BIZID)
Expand All @@ -479,7 +479,7 @@ class PipelineTriggerEventService @Autowired constructor(
buildId = buildId,
buildNum = buildNum,
pipelineName = pipelineName,
reason = failReason
reason = reason
),
triggerEvent = PipelineTriggerEvent(
eventId = eventId,
Expand All @@ -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 -> ""
}

Expand Down
2 changes: 1 addition & 1 deletion support-files/i18n/process/message_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ bkGithubPrEventDesc=Pull request [<a href="{0}" target="_blank">!{1}</a>] by <sp
bkP4EventDesc=Change [{0}] by <span style="color: #979BA5;">{1}</span> {2}
bkSvnCommitEventDesc=Commit [{0}] pushed by <span style="color: #979BA5;">{1}</span>
bkManualStartEventDesc=Manually triggered by <span style="color: #979BA5;">{0}</span>
bkRemoteStartEventDesc=Remote api triggered by <span style="color: #979BA5;">{0}</span>
bkRemoteStartEventDesc=Remote api triggered by <span style="color: #979BA5;">{1} [{0}]</span>
bkServiceStartEventDesc=Pipeline invocation triggered by <span style="color: #979BA5;">{0}</span> invoke
bkPipelinetartEventDesc=Pipeline invocation [<a href="{1}" target="_blank">{2}</a>] triggered by <span style="color: #979BA5;">{0}</span> invoke
bkTimingStartEventDesc=Timer triggered by <span style="color: #979BA5;">{0}</span>
Expand Down
2 changes: 1 addition & 1 deletion support-files/i18n/process/message_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ bkGithubPrEventDesc=Pull request [<a href="{0}" target="_blank">{1}</a>] 由 <s
bkP4EventDesc=Change {0} 由 <span style="color: #979BA5;">{1}</span> {2}
bkSvnCommitEventDesc=提交 [{0}] 由 <span style="color: #979BA5;">{1}</span> 推送
bkManualStartEventDesc=<span style="color: #979BA5;">{0}</span> 手动触发
bkRemoteStartEventDesc=<span style="color: #979BA5;">{0}</span> 远程触发
bkRemoteStartEventDesc=<span style="color: #979BA5;">{1} [{0}]</span> 远程触发
bkServiceStartEventDesc=<span style="color: #979BA5;">{0}</span> 触发的流水线调用
bkPipelinetartEventDesc=<span style="color: #979BA5;">{0}</span> 触发的流水线 [<a href="{1}" target="_blank">{2}</a>] 调用
bkTimingStartEventDesc=<span style="color: #979BA5;">{0}</span> 定时触发
Expand Down

0 comments on commit bb2228e

Please sign in to comment.