From 919932e0de34f385c3412c1a0509a2f7a70cce9c Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 9 Nov 2023 17:43:24 +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 --- docs/overview/db/devops_ci_process.md | 46 +++++++++++++++++++ .../github/GithubCreateTriggerHandler.kt | 5 +- .../github/GithubPushTriggerHandler.kt | 5 +- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/docs/overview/db/devops_ci_process.md b/docs/overview/db/devops_ci_process.md index 354bf30c323..500da903438 100644 --- a/docs/overview/db/devops_ci_process.md +++ b/docs/overview/db/devops_ci_process.md @@ -58,6 +58,8 @@ | [T_TEMPLATE_INSTANCE_BASE](#T_TEMPLATE_INSTANCE_BASE) | 模板实列化基本信息表 | | [T_TEMPLATE_INSTANCE_ITEM](#T_TEMPLATE_INSTANCE_ITEM) | 模板实列化项信息表 | | [T_TEMPLATE_PIPELINE](#T_TEMPLATE_PIPELINE) | 流水线模板-实例映射表 | +| [T_PIPELINE_TRIGGER_EVENT](#T_PIPELINE_TRIGGER_EVENT) | 流水线触发事件表 | +| [T_PIPELINE_TRIGGER_DETAIL](#T_PIPELINE_TRIGGER_DETAIL) | 流水线触发事件明细表 | **表名:** T_AUDIT_RESOURCE @@ -846,6 +848,9 @@ | 8 | PROJECT_NAME | varchar | 128 | 0 | Y | N | | 项目名称 | | 9 | TASK_ID | varchar | 34 | 0 | Y | N | | 任务id | | 10 | DELETE | bit | 1 | 0 | Y | N | b'0' | 是否删除 | +| 11 | EXTERNAL_ID | varchar | 255 | 0 | Y | N | | webhook事件生产者ID,工蜂-工蜂ID,github-github id,svn-svn path,p4-p4port | +| 12 | EVENT_TYPE | varchar | 32 | 0 | Y | N | | 事件类型 | +| 13 | REPOSITORY_HASH_ID | varchar | 64 | 0 | Y | N | | 代码库hashId | **表名:** T_PIPELINE_WEBHOOK_QUEUE @@ -1016,3 +1021,44 @@ | 12 | BUILD_NO | text | 65535 | 0 | Y | N | | 构建号 | | 13 | PARAM | mediumtext | 16777215 | 0 | Y | N | | 参数 | | 14 | DELETED | bit | 1 | 0 | Y | N | b'0' | 流水线已被软删除 | + +**表名:** T_PIPELINE_TRIGGER_EVENT + +**说明:** 流水线触发事件表 + +**数据列:** + +| 序号 | 名称 | 数据类型 | 长度 | 小数位 | 允许空值 | 主键 | 默认值 | 说明 | +| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| 1 | REQUEST_ID | varchar | 64 | 0 | N | N | | 请求ID | +| 2 | PROJECT_ID | varchar | 64 | 0 | N | Y | | 项目ID | +| 3 | EVENT_ID | bigint | 20 | 0 | N | Y | | 事件ID | +| 4 | TRIGGER_TYPE | varchar | 32 | 0 | N | N | | 触发类型 | +| 5 | EVENT_SOURCE | varchar | 20 | 0 | N | N | | 触发源,代码库hashId/触发人/远程ip | +| 6 | EVENT_TYPE | varchar | 64 | 0 | N | N | | 事件类型 | +| 7 | TRIGGER_USER | varchar | 100 | 0 | N | N | | 触发用户 | +| 8 | EVENT_DESC | text | | 0 | N | N | | 事件描述 | +| 9 | REPLAY_REQUEST_ID | varchar | 64 | 0 | Y | N | | 重放请求ID | +| 10 | REQUEST_PARAMS | text | | 0 | N | N | | 请求参数 | +| 11 | CREATE_TIME | timestamp | | 0 | N | Y | | 事件时间 | + +**表名:** T_PIPELINE_TRIGGER_DETAIL + +**说明:** 流水线触发事件明细表 + +**数据列:** + +| 序号 | 名称 | 数据类型 | 长度 | 小数位 | 允许空值 | 主键 | 默认值 | 说明 | +| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| 1 | DETAIL_ID | varchar | 64 | 0 | N | Y | | 事件明细ID | +| 2 | PROJECT_ID | varchar | 64 | 0 | N | N | | 项目ID | +| 3 | EVENT_ID | bigint | 20 | 0 | N | N | | 事件ID | +| 4 | STATUS | varchar | 32 | 0 | Y | N | | 状态(success or failure) | +| 5 | PIPELINE_ID | varchar | 20 | 0 | Y | N | | 流水线ID | +| 6 | PIPELINE_NAME | varchar | 64 | 0 | Y | N | | 流水线名称 | +| 7 | VERSION | varchar | 100 | 0 | Y | N | | 流水线版本号 | +| 8 | BUILD_ID | text | | 0 | Y | N | | 构建ID | +| 9 | BUILD_NUM | varchar | 64 | 0 | Y | N | | 构建编号 | +| 10 | REASON | text | | 0 | Y | N | | 失败原因 | +| 11 | REASON_DETAIL | timestamp | | 0 | Y | N | | 原因详情 | +| 12 | CREATE_TIME | timestamp | | 0 | Y | Y | | 创建时间 | \ No newline at end of file diff --git a/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubCreateTriggerHandler.kt b/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubCreateTriggerHandler.kt index a665d5e1147..5662194f712 100644 --- a/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubCreateTriggerHandler.kt +++ b/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubCreateTriggerHandler.kt @@ -35,6 +35,7 @@ import com.tencent.devops.common.webhook.pojo.code.BK_REPO_GITHUB_WEBHOOK_CREATE import com.tencent.devops.common.webhook.pojo.code.BK_REPO_GITHUB_WEBHOOK_CREATE_REF_TYPE import com.tencent.devops.common.webhook.pojo.code.BK_REPO_GITHUB_WEBHOOK_CREATE_USERNAME import com.tencent.devops.common.webhook.pojo.code.WebHookParams +import com.tencent.devops.common.webhook.pojo.code.github.GithubBaseInfo import com.tencent.devops.common.webhook.pojo.code.github.GithubCreateEvent import com.tencent.devops.common.webhook.service.code.filter.WebhookFilter import com.tencent.devops.common.webhook.service.code.handler.GitHookTriggerHandler @@ -78,10 +79,10 @@ class GithubCreateTriggerHandler : GitHookTriggerHandler { override fun getEventDesc(event: GithubCreateEvent): String { val (i18Code, linkUrl) = if (event.ref_type == "tag") { WebhookI18nConstants.GITHUB_CREATE_TAG_EVENT_DESC to - "https://github.com/${event.repository.fullName}/releases/tag/${event.ref}" + "${GithubBaseInfo.GITHUB_HOME_PAGE_URL}/${event.repository.fullName}/releases/tag/${event.ref}" } else { WebhookI18nConstants.GITHUB_CREATE_BRANCH_EVENT_DESC to - "https://github.com/${event.repository.fullName}/tree/${event.ref}" + "${GithubBaseInfo.GITHUB_HOME_PAGE_URL}/${event.repository.fullName}/tree/${event.ref}" } // 事件重放 return I18Variable( diff --git a/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubPushTriggerHandler.kt b/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubPushTriggerHandler.kt index 5d31becdac4..c9b0bd43930 100644 --- a/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubPushTriggerHandler.kt +++ b/src/backend/ci/core/common/common-webhook/biz-common-webhook/src/main/kotlin/com/tencent/devops/common/webhook/service/code/handler/github/GithubPushTriggerHandler.kt @@ -54,6 +54,7 @@ import com.tencent.devops.common.webhook.pojo.code.WebHookParams import com.tencent.devops.common.webhook.pojo.code.git.GitCommit import com.tencent.devops.common.webhook.pojo.code.git.GitCommitAuthor import com.tencent.devops.common.webhook.pojo.code.git.GitPushEvent +import com.tencent.devops.common.webhook.pojo.code.github.GithubBaseInfo import com.tencent.devops.common.webhook.pojo.code.github.GithubPushEvent import com.tencent.devops.common.webhook.service.code.filter.BranchFilter import com.tencent.devops.common.webhook.service.code.filter.UserFilter @@ -107,9 +108,9 @@ class GithubPushTriggerHandler : GitHookTriggerHandler { override fun getEventDesc(event: GithubPushEvent): String { val linkUrl = if (event.headCommit != null) { - "https://github.com/${event.repository.fullName}/commit/${event.headCommit?.id}" + "${GithubBaseInfo.GITHUB_HOME_PAGE_URL}/${event.repository.fullName}/commit/${event.headCommit?.id}" } else { - "https://github.com/${event.repository.fullName}/commit/${getBranchName(event)}" + "${GithubBaseInfo.GITHUB_HOME_PAGE_URL}/${event.repository.fullName}/commit/${getBranchName(event)}" } val revision = getRevision(event) val commitId = if (revision.isNotBlank()) {