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 9, 2023
1 parent 02c5cf1 commit 919932e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
46 changes: 46 additions & 0 deletions docs/overview/db/devops_ci_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | 流水线触发事件明细表 |

**表名:** <a id="T_AUDIT_RESOURCE">T_AUDIT_RESOURCE</a>

Expand Down Expand Up @@ -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 |


**表名:** <a id="T_PIPELINE_WEBHOOK_QUEUE">T_PIPELINE_WEBHOOK_QUEUE</a>
Expand Down Expand Up @@ -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' | 流水线已被软删除 |

**表名:** <a id="T_PIPELINE_TRIGGER_EVENT">T_PIPELINE_TRIGGER_EVENT</a>

**说明:** 流水线触发事件表

**数据列:**

| 序号 | 名称 | 数据类型 | 长度 | 小数位 | 允许空值 | 主键 | 默认值 | 说明 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 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 | | 事件时间 |

**表名:** <a id="T_PIPELINE_TRIGGER_DETAIL">T_PIPELINE_TRIGGER_DETAIL</a>

**说明:** 流水线触发事件明细表

**数据列:**

| 序号 | 名称 | 数据类型 | 长度 | 小数位 | 允许空值 | 主键 | 默认值 | 说明 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 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 | | 创建时间 |
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,10 +79,10 @@ class GithubCreateTriggerHandler : GitHookTriggerHandler<GithubCreateEvent> {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -107,9 +108,9 @@ class GithubPushTriggerHandler : GitHookTriggerHandler<GithubPushEvent> {

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()) {
Expand Down

0 comments on commit 919932e

Please sign in to comment.