Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:流水线代码变更记录,支持 AI 生成摘要 #11228 #11349

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
7fb684f
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 4, 2024
3084f53
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 5, 2024
af33a4f
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 10, 2024
62f82b3
Merge branch 'master' of https://github.com/TencentBlueKing/bk-ci int…
hejieehe Dec 10, 2024
553db99
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 10, 2024
62d6648
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 10, 2024
b47ebc0
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 12, 2024
0320a6f
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 13, 2024
0283636
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 13, 2024
4485637
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 13, 2024
8ff9ada
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Dec 24, 2024
da84276
feat:流水线代码变更记录,支持 AI 生成摘要 #11228 补充SQL
hejieehe Dec 26, 2024
8a24267
Merge branch 'master' of https://github.com/TencentBlueKing/bk-ci int…
hejieehe Jan 2, 2025
596b279
feat:流水线代码变更记录,支持 AI 生成摘要 #11228 补充SQL
hejieehe Jan 2, 2025
f511906
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Jan 2, 2025
4c1d5e7
feat:流水线代码变更记录,支持 AI 生成摘要 #11228
hejieehe Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ object CommonMessageCode {
const val DISPATCH_NOT_SUPPORT_TRANSFER = "2100129" // 如下构建环境在 Code 方式下不支持转换,请修改后再切换: \n[{0}]
const val YAML_NOT_VALID = "2100130" // yaml不合法 {0}
const val GIT_INVALID_PRIVATE_KEY = "2100131" // 不支持的SSH私钥格式,仅支持rsa格式私钥
const val GIT_INVALID_PRIVATE_KEY_OR_PASSWORD = "2100132" // 第三方服务[{0}]操作失败,失败详情:{1}
const val THIRD_PARTY_SERVICE_OPERATION_FAILED = "2100132" // 第三方服务[{0}]操作失败,失败详情:{1}
const val MR_ACCEPT_EVENT_NOT_SUPPORT_TRANSFER = "2100133" // mr accept事件类型不支持code转换

const val SVN_TOKEN_FAIL = "2100135" // SVN Token 不正确
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CodeGitScmImpl constructor(
logger.warn("Fail to list all branches", ignored)
throw ScmException(
I18nUtil.getCodeLanMessage(
CommonMessageCode.GIT_INVALID_PRIVATE_KEY_OR_PASSWORD,
CommonMessageCode.THIRD_PARTY_SERVICE_OPERATION_FAILED,
params = arrayOf(ScmType.CODE_GIT.name, ignored.message ?: "")
),
ScmType.CODE_GIT.name
Expand Down Expand Up @@ -161,7 +161,7 @@ class CodeGitScmImpl constructor(
logger.warn("Fail to list all branches", ignored)
throw ScmException(
I18nUtil.getCodeLanMessage(
CommonMessageCode.GIT_INVALID_PRIVATE_KEY_OR_PASSWORD,
CommonMessageCode.THIRD_PARTY_SERVICE_OPERATION_FAILED,
params = arrayOf(ScmType.CODE_GIT.name, ignored.message ?: "")
),
ScmType.CODE_GIT.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class CodeGitlabScmImpl constructor(
logger.warn("Fail to check the gitlab token", ignored)
throw ScmException(
I18nUtil.getCodeLanMessage(
CommonMessageCode.GIT_INVALID_PRIVATE_KEY_OR_PASSWORD,
CommonMessageCode.THIRD_PARTY_SERVICE_OPERATION_FAILED,
params = arrayOf(ScmType.CODE_GITLAB.name, ignored.message ?: "")
),
ScmType.CODE_GITLAB.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CodeTGitScmImpl constructor(
logger.warn("Fail to list all branches", ignored)
throw ScmException(
I18nUtil.getCodeLanMessage(
CommonMessageCode.GIT_INVALID_PRIVATE_KEY_OR_PASSWORD,
CommonMessageCode.THIRD_PARTY_SERVICE_OPERATION_FAILED,
params = arrayOf(ScmType.CODE_TGIT.name, ignored.message ?: "")
),
ScmType.CODE_TGIT.name
Expand Down Expand Up @@ -153,7 +153,7 @@ class CodeTGitScmImpl constructor(
logger.warn("Fail to list all branches", ignored)
throw ScmException(
I18nUtil.getCodeLanMessage(
CommonMessageCode.GIT_INVALID_PRIVATE_KEY_OR_PASSWORD,
CommonMessageCode.THIRD_PARTY_SERVICE_OPERATION_FAILED,
params = arrayOf(ScmType.CODE_TGIT.name, ignored.message ?: "")
),
ScmType.CODE_TGIT.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,7 @@ class GitConfig {

@Value("\${scm.external.tGit.hookSecret:}")
val tGitHookSecret: String = ""

@Value("\${scm.git.copilot.crApiUrl:}")
val copilotUrl: String = ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-CI 蓝鲸持续集成平台 is licensed under the MIT license.
*
* A copy of the MIT License is included in this file.
*
*
* Terms of the MIT License:
* ---------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.tencent.devops.scm.enums

/**
* 针对[AI 摘要]的评论类型
*/
enum class AISummaryRateType constructor(val value: String) {
UP("up"),
DOWN("down")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.tencent.devops.scm.pojo

import io.swagger.v3.oas.annotations.media.Schema

/**
* 工蜂Copilot摘要返回值
*/
@Schema(title = "工蜂Copilot摘要返回值")
data class CodeGitCopilotSummary(
@get:Schema(title = "id")
val number: Int? = null,
@get:Schema(title = "任务id, 后续好评差评使用的是这个 id")
val processId: String? = null,
@get:Schema(title = "状态 1:运行中 3:失败 5:已生成")
val status: Int,
@get:Schema(title = "大模型回答原始文本")
val resultRaw: String? = null,
@get:Schema(title = "markdown 渲染后的回答文本")
val resultHtml: String? = null,
@get:Schema(title = "随机值")
val lastPatchSetId: String? = null,
@get:Schema(title = "创建时间")
val createdAt: Long? = null,
@get:Schema(title = "仓库名称")
var projectName: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ object RepositoryMessageCode {

const val USER_NOT_PERMISSIONS_OPERATE_REPOSITORY = "2115046" // 用户({0})无权限在工程({1})下{2}流水线{3}
const val FAIL_TO_GET_OPEN_COPILOT_TOKEN = "2115048" // 获取open copilot token 失败, 失败详情: {0}
const val EMPTY_COMMIT_RECORD = "2115050" // 无代码变更记录
const val REPOSITORY_NO_SUPPORT_AI_SUMMARY = "2115051" // 仅支持工蜂代码库生成AI摘要,

const val BK_REQUEST_FILE_SIZE_LIMIT = "bkRequestFileSizeLimit" // 请求文件不能超过1M
const val OPERATION_ADD_CHECK_RUNS = "OperationAddCheckRuns" // 添加检测任务
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,18 @@ class CommitDao {
.fetch()
}
}

fun list(
dslContext: DSLContext,
buildId: String,
pipelineId: String,
elementId: String
): Result<TRepositoryCommitRecord> {
with(TRepositoryCommit.T_REPOSITORY_COMMIT) {
return dslContext.selectFrom(this)
.where(PIPELINE_ID.eq(pipelineId).and(ELEMENT_ID.eq(elementId)).and(BUILD_ID.eq(buildId)))
.orderBy(COMMIT_TIME.desc())
.fetch()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,10 @@ class CommitService @Autowired constructor(
)
}
}

fun list(
buildId: String,
pipelineId: String,
elementId: String
) = commitDao.list(dslContext, buildId, pipelineId, elementId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -1423,13 +1423,13 @@ class RepositoryService @Autowired constructor(
}

fun getRepository(projectId: String, repositoryHashId: String?, repoAliasName: String?): Repository {
if (repoAliasName.isNullOrBlank() && repoAliasName.isNullOrBlank()) {
if (repositoryHashId.isNullOrBlank() && repoAliasName.isNullOrBlank()) {
throw IllegalArgumentException("repositoryHashId or repoAliasName can not be null")
}
return compose(
getRepository(
projectId = projectId,
repositoryConfig = if (repositoryHashId.isNullOrBlank()) {
repositoryConfig = if (!repositoryHashId.isNullOrBlank()) {
RepositoryConfig(
repositoryHashId = repositoryHashId,
repositoryName = null,
Expand Down
2 changes: 2 additions & 0 deletions support-files/i18n/repository/message_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
2115049=OAuth auth info occupied, can't delete
2100054=User ({0}) does not have permission to {2} repository {3} under project ({1}).
2115048=Failed to get open copilot token, failure details: {0}
2115050=No code change record
2115051=The current repository does not support generating AI summarie
bkRequestFileSizeLimit=The request file cannot exceed 1m
OperationAddCheckRuns=Add a detection task
OperationUpdateCheckRuns=Update the detection task
Expand Down
2 changes: 2 additions & 0 deletions support-files/i18n/repository/message_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
2115046=用户({0})无权限在工程({1})下{2}代码库{3}
2115048=获取open copilot token 失败, 失败详情: {0}
2115049=OAUTH授权信息被占用, 无法删除
2115050=无代码变更记录
2115051=仅支持工蜂代码库生成AI摘要
bkRequestFileSizeLimit=请求文件不能超过1M
OperationAddCheckRuns=添加检测任务
OperationUpdateCheckRuns=更新检测任务
Expand Down
14 changes: 14 additions & 0 deletions support-files/sql/1001_ci_repository_ddl_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,18 @@ CREATE TABLE IF NOT EXISTS `T_REPOSITORY_SCM_TOKEN` (
UNIQUE KEY `UNIQ_USER_SCM_CODE_APP_TYPE` (`USER_ID`,`SCM_CODE`,`APP_TYPE`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='代码仓库token表';

CREATE TABLE `T_REPOSITORY_COPILOT_SUMMARY` (
`PROJECT_ID` varchar(64) NOT NULL COMMENT '蓝盾项目ID',
`BUILD_ID` varchar(64) NOT NULL COMMENT '构建ID',
`ELEMENT_ID` varchar(64) NOT NULL COMMENT '插件ID',
`SCM_TYPE` varchar(32) DEFAULT NULL COMMENT '代码库类型',
`PROJECT_NAME` varchar(255) DEFAULT NULL COMMENT '仓库唯一标识',
`SOURCE_COMMIT` varchar(64) DEFAULT NULL COMMENT '源提交点',
`TARGET_COMMIT` varchar(64) DEFAULT NULL COMMENT '目标提交点',
`STATUS` int(11) DEFAULT NULL COMMENT '生成状态,1-生成中,3-生成失败, 5-生成成功',
`SUMMARY` text COMMENT 'AI 摘要',
`CREATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`PROJECT_ID`,`BUILD_ID`,`ELEMENT_ID`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='代码库copilot摘要表';

SET FOREIGN_KEY_CHECKS = 1;
Loading