@kevisual/cnb 0.0.40 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/app.ts +0 -1
- package/agent/routes/build/docker.ts +66 -0
- package/agent/routes/build/index.ts +1 -0
- package/agent/routes/index.ts +1 -0
- package/agent/routes/issues/comments.ts +167 -0
- package/agent/routes/issues/index.ts +2 -1
- package/agent/routes/issues/list.ts +2 -2
- package/dist/cli.js +439 -101
- package/dist/keep.js +34 -16
- package/dist/opencode.js +435 -97
- package/dist/routes.d.ts +59 -1
- package/dist/routes.js +430 -92
- package/package.json +1 -1
- package/src/index.ts +14 -1
- package/src/issue/index.ts +58 -2
- package/src/issue/npc/env.ts +417 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -67,4 +67,17 @@ export * from './user/index.ts'
|
|
|
67
67
|
export * from './build/index.ts'
|
|
68
68
|
export * from './issue/index.ts'
|
|
69
69
|
export * from './mission/index.ts'
|
|
70
|
-
export * from './ai/index.ts'
|
|
70
|
+
export * from './ai/index.ts'
|
|
71
|
+
|
|
72
|
+
export const getCNBVersion = () => {
|
|
73
|
+
const url = 'https://cnb.cool/api/version';
|
|
74
|
+
// {"version":"1.18.8-2e3e01f0-20260309","commitID":"2e3e01f0","hash":"897b088418dccd05"}
|
|
75
|
+
return fetch(url).then(res => res.json()) as Promise<VersionInfo>;
|
|
76
|
+
}
|
|
77
|
+
type VersionInfo = {
|
|
78
|
+
version: string;
|
|
79
|
+
commitID: string;
|
|
80
|
+
hash: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export * from './issue/npc/env.ts'
|
package/src/issue/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
|
2
2
|
import { extractAliveInfo } from "./issue-alive.ts";
|
|
3
|
-
|
|
3
|
+
import { useNPCEnv, useCommentEnv, usePullRequestEnv, useRepoInfoEnv } from "./npc/env.ts";
|
|
4
4
|
export type IssueAssignee = {
|
|
5
5
|
nickname: string;
|
|
6
6
|
username: string;
|
|
@@ -22,6 +22,26 @@ export type IssueAuthor = {
|
|
|
22
22
|
ended_at: string;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
export type IssueCommentUser = {
|
|
26
|
+
username: string;
|
|
27
|
+
nickname: string;
|
|
28
|
+
avatar: string;
|
|
29
|
+
is_npc: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type IssueCommentReaction = {
|
|
33
|
+
// 根据实际返回数据补充
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type IssueComment = {
|
|
37
|
+
id: string;
|
|
38
|
+
body: string;
|
|
39
|
+
author: IssueCommentUser;
|
|
40
|
+
reactions: IssueCommentReaction[];
|
|
41
|
+
created_at: string;
|
|
42
|
+
updated_at: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
25
45
|
export type IssueItem = {
|
|
26
46
|
assignees: IssueAssignee[];
|
|
27
47
|
author: IssueAuthor;
|
|
@@ -76,10 +96,34 @@ export class Issue extends CNBCore {
|
|
|
76
96
|
}
|
|
77
97
|
});
|
|
78
98
|
}
|
|
79
|
-
getCommentList(repo: string, issueNumber: string | number): Promise<
|
|
99
|
+
getCommentList(repo: string, issueNumber: string | number, params?: { page?: number; page_size?: number }): Promise<Result<IssueComment[]>> {
|
|
80
100
|
const url = `/${repo}/-/issues/${issueNumber}/comments`;
|
|
81
101
|
return this.get({
|
|
82
102
|
url,
|
|
103
|
+
params,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getComment(repo: string, issueNumber: string | number, commentId: string | number): Promise<Result<IssueComment>> {
|
|
108
|
+
const url = `/${repo}/-/issues/${issueNumber}/comments/${commentId}`;
|
|
109
|
+
return this.get({
|
|
110
|
+
url,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
createComment(repo: string, issueNumber: string | number, body: string): Promise<Result<IssueComment>> {
|
|
115
|
+
const url = `/${repo}/-/issues/${issueNumber}/comments`;
|
|
116
|
+
return this.post({
|
|
117
|
+
url,
|
|
118
|
+
data: { body },
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
updateComment(repo: string, issueNumber: string | number, commentId: string | number, body: string): Promise<Result<IssueComment>> {
|
|
123
|
+
const url = `/${repo}/-/issues/${issueNumber}/comments/${commentId}`;
|
|
124
|
+
return this.patch({
|
|
125
|
+
url,
|
|
126
|
+
data: { body },
|
|
83
127
|
});
|
|
84
128
|
}
|
|
85
129
|
setIssueProperty(repo: string, issueNumber: string | number, properties: { [key: string]: any }[]): Promise<any> {
|
|
@@ -134,6 +178,18 @@ export class Issue extends CNBCore {
|
|
|
134
178
|
},
|
|
135
179
|
};
|
|
136
180
|
}
|
|
181
|
+
useNPCEnv() {
|
|
182
|
+
return useNPCEnv();
|
|
183
|
+
}
|
|
184
|
+
useCommentEnv() {
|
|
185
|
+
return useCommentEnv();
|
|
186
|
+
}
|
|
187
|
+
usePullRequestEnv() {
|
|
188
|
+
return usePullRequestEnv();
|
|
189
|
+
}
|
|
190
|
+
useRepoInfoEnv() {
|
|
191
|
+
return useRepoInfoEnv();
|
|
192
|
+
}
|
|
137
193
|
}
|
|
138
194
|
|
|
139
195
|
type GetListParams = {
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
// CNB_NPC_SLUG 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库路径,否则为空字符串
|
|
2
|
+
// CNB_NPC_NAME 对于 NPC 事件触发的构建,值为 NPC 角色名,否则为空字符串
|
|
3
|
+
// CNB_NPC_SHA 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库默认分支最新提交的 sha,否则为空字符串
|
|
4
|
+
// CNB_NPC_PROMPT 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色 Prompt,否则为空字符串
|
|
5
|
+
// CNB_NPC_AVATAR 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色头像,否则为空字符串
|
|
6
|
+
// CNB_NPC_ENABLE_THINKING 对于 @npc 事件触发的构建,值为 NPC 角色是否开启思考,否则为空字符串
|
|
7
|
+
import { useKey } from "@kevisual/context";
|
|
8
|
+
|
|
9
|
+
export function useNPCEnv() {
|
|
10
|
+
const npcSlug = useKey("CNB_NPC_SLUG");
|
|
11
|
+
const npcName = useKey("CNB_NPC_NAME");
|
|
12
|
+
const npcSha = useKey("CNB_NPC_SHA");
|
|
13
|
+
const npcPrompt = useKey("CNB_NPC_PROMPT");
|
|
14
|
+
const npcAvatar = useKey("CNB_NPC_AVATAR");
|
|
15
|
+
const npcEnableThinking = useKey("CNB_NPC_ENABLE_THINKING");
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
/**
|
|
19
|
+
* @key CNB_NPC_SLUG
|
|
20
|
+
* @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库路径,否则为空字符串
|
|
21
|
+
*/
|
|
22
|
+
npcSlug,
|
|
23
|
+
/**
|
|
24
|
+
* @key CNB_NPC_NAME
|
|
25
|
+
* @description:对于 NPC 事件触发的构建,值为 NPC 角色名,否则为空字符串
|
|
26
|
+
*/
|
|
27
|
+
npcName,
|
|
28
|
+
/**
|
|
29
|
+
* @key CNB_NPC_SHA
|
|
30
|
+
* @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库默认分支最新提交的 sha,否则为空字符串
|
|
31
|
+
*/
|
|
32
|
+
npcSha,
|
|
33
|
+
/**
|
|
34
|
+
* @key CNB_NPC_PROMPT
|
|
35
|
+
* @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色 Prompt,否则为空字符串
|
|
36
|
+
*/
|
|
37
|
+
npcPrompt,
|
|
38
|
+
/**
|
|
39
|
+
* @key CNB_NPC_AVATAR
|
|
40
|
+
* @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色头像,否则为空字符串
|
|
41
|
+
*/
|
|
42
|
+
npcAvatar,
|
|
43
|
+
/**
|
|
44
|
+
* @key CNB_NPC_ENABLE_THINKING
|
|
45
|
+
* @description:对于 @npc 事件触发的构建,值为 NPC 角色是否开启思考,否则为空字符串
|
|
46
|
+
*/
|
|
47
|
+
npcEnableThinking
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// CNB_COMMENT_ID 对于评论事件触发的构建,值为评论全局唯一 ID,否则为空字符串
|
|
52
|
+
// CNB_COMMENT_BODY 对于评论事件触发的构建,值为评论内容,否则为空字符串
|
|
53
|
+
// CNB_COMMENT_TYPE note 对于 PR 代码评审评论,值为 diff_note;对于 PR 非代码评审评论以及 Issue 评论,值为 note;否则为空字符串
|
|
54
|
+
// CNB_COMMENT_FILE_PATH 对于 PR 代码评审评论,值为评论所在文件,否则为空字符串
|
|
55
|
+
// CNB_COMMENT_RANGE 对于 PR 代码评审评论,值为评论所在代码行。如,单行为 L12,多行为 L13-L16,否则为空字符串
|
|
56
|
+
// CNB_REVIEW_ID 对于 PR 代码评审,值为评审 ID,否则为空字符串
|
|
57
|
+
|
|
58
|
+
export function useCommentEnv() {
|
|
59
|
+
const commentId = useKey("CNB_COMMENT_ID");
|
|
60
|
+
const commentBody = useKey("CNB_COMMENT_BODY");
|
|
61
|
+
const commentType = useKey("CNB_COMMENT_TYPE");
|
|
62
|
+
const commentFilePath = useKey("CNB_COMMENT_FILE_PATH");
|
|
63
|
+
const commentRange = useKey("CNB_COMMENT_RANGE");
|
|
64
|
+
const reviewId = useKey("CNB_REVIEW_ID");
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
/**
|
|
68
|
+
* @key CNB_COMMENT_ID
|
|
69
|
+
* @description:对于评论事件触发的构建,值为评论全局唯一 ID,否则为空字符串
|
|
70
|
+
*/
|
|
71
|
+
commentId,
|
|
72
|
+
/**
|
|
73
|
+
* @key CNB_COMMENT_BODY
|
|
74
|
+
* @description:对于评论事件触发的构建,值为评论内容,否则为空字符串
|
|
75
|
+
*/
|
|
76
|
+
commentBody,
|
|
77
|
+
/**
|
|
78
|
+
* @key CNB_COMMENT_TYPE
|
|
79
|
+
* @description:note 对于 PR 代码评审评论,值为 diff_note;对于 PR 非代码评审评论以及 Issue 评论,值为 note;否则为空字符串
|
|
80
|
+
*/
|
|
81
|
+
commentType,
|
|
82
|
+
/**
|
|
83
|
+
* @key CNB_COMMENT_FILE_PATH
|
|
84
|
+
* @description:对于 PR 代码评审评论,值为评论所在文件,否则为空字符串
|
|
85
|
+
*/
|
|
86
|
+
commentFilePath,
|
|
87
|
+
/**
|
|
88
|
+
* @key CNB_COMMENT_RANGE
|
|
89
|
+
* @description:对于 PR 代码评审评论,值为评论所在代码行。如,单行为 L12,多行为 L13-L16,否则为空字符串
|
|
90
|
+
*/
|
|
91
|
+
commentRange,
|
|
92
|
+
/**
|
|
93
|
+
* @key CNB_REVIEW_ID
|
|
94
|
+
* @description:对于 PR 代码评审,值为评审 ID,否则为空字符串
|
|
95
|
+
*/
|
|
96
|
+
reviewId
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// CNB_BUILD_ID cnb-75b-1jj9hnk99 当前构建的流水号,全局唯一
|
|
101
|
+
// CNB_BUILD_WEB_URL https://cnb.cool/kevision/dev-cnb/-/build/logs/cnb-75b-1jj9hnk99 当前构建的日志地址
|
|
102
|
+
// CNB_BUILD_START_TIME 2026-03-09T14:59:01.550Z 当前构建的开始时间,UTC 格式,示例 2025-08-21T09:13:45.803Z
|
|
103
|
+
// CNB_BUILD_USER xiongxiao 当前构建的触发者用户名
|
|
104
|
+
// CNB_BUILD_USER_NICKNAME 小熊猫呜呜呜 当前构建的触发者昵称
|
|
105
|
+
// CNB_BUILD_USER_EMAIL kevisual@xiongxiao.me 当前构建的触发者邮箱
|
|
106
|
+
// CNB_BUILD_USER_ID 1935321989751226368 当前构建的触发者 id
|
|
107
|
+
// CNB_BUILD_USER_NPC_SLUG 当前构建若为 NPC 触发,则为 NPC 所属仓库的路径
|
|
108
|
+
// CNB_BUILD_USER_NPC_NAME 当前构建若为 NPC 触发,则为 NPC 角色名
|
|
109
|
+
// CNB_BUILD_STAGE_NAME 初始化开发机 当前构建的 stage 名称
|
|
110
|
+
// CNB_BUILD_JOB_NAME 初始化开发机 当前构建的 job 名称
|
|
111
|
+
// CNB_BUILD_JOB_KEY job-0 当前构建的 job key,同 stage 下唯一
|
|
112
|
+
// CNB_BUILD_WORKSPACE /workspace/ 自定义 shell 脚本执行的工作空间根目录
|
|
113
|
+
// CNB_BUILD_FAILED_MSG 流水线构建失败的错误信息,可在 failStages 中使用
|
|
114
|
+
// CNB_BUILD_FAILED_STAGE_NAME 流水线构建失败的 stage 的名称,可在 failStages 中使用
|
|
115
|
+
// CNB_PIPELINE_NAME pipeline-1 当前 pipeline 的 name,没声明时为空
|
|
116
|
+
// CNB_PIPELINE_KEY pipeline-1 当前 pipeline 的索引 key,例如 pipeline-0
|
|
117
|
+
// CNB_PIPELINE_ID cnb-75b-1jj9hnk99-001 当前 pipeline 的 id,全局唯一字符串
|
|
118
|
+
// CNB_PIPELINE_DOCKER_IMAGE docker.cnb.cool/kevisual/dev-env:latest 当前 pipeline 所使用的 docker image,如:alpine:latest
|
|
119
|
+
// CNB_PIPELINE_STATUS 当前流水线的构建状态,可在 endStages 中查看,其可能的值包括:success、error、cancel
|
|
120
|
+
// CNB_PIPELINE_MAX_RUN_TIME 72000000 流水线最大运行时间,单位为毫秒
|
|
121
|
+
// CNB_RUNNER_IP 10.235.16.3 当前 pipeline 所在 Runner 的 ip
|
|
122
|
+
// CNB_CPUS 16 当前构建流水线可以使用的最大 CPU 核数
|
|
123
|
+
// CNB_MEMORY 32 当前构建流水线可以使用的最大内存大小,单位为 GiB
|
|
124
|
+
// CNB_IS_RETRY false 当前构建是否由 rebuild 触发
|
|
125
|
+
// HUSKY_SKIP_INSTALL 1 兼容 ci 环境下 husky
|
|
126
|
+
export const useBuildEnv = () => {
|
|
127
|
+
const buildId = useKey("CNB_BUILD_ID");
|
|
128
|
+
const buildWebUrl = useKey("CNB_BUILD_WEB_URL");
|
|
129
|
+
const buildStartTime = useKey("CNB_BUILD_START_TIME");
|
|
130
|
+
const buildUser = useKey("CNB_BUILD_USER");
|
|
131
|
+
const buildUserNickname = useKey("CNB_BUILD_USER_NICKNAME");
|
|
132
|
+
const buildUserEmail = useKey("CNB_BUILD_USER_EMAIL");
|
|
133
|
+
const buildUserId = useKey("CNB_BUILD_USER_ID");
|
|
134
|
+
const buildUserNpcSlug = useKey("CNB_BUILD_USER_NPC_SLUG");
|
|
135
|
+
const buildUserNpcName = useKey("CNB_BUILD_USER_NPC_NAME");
|
|
136
|
+
const buildStageName = useKey("CNB_BUILD_STAGE_NAME");
|
|
137
|
+
const buildJobName = useKey("CNB_BUILD_JOB_NAME");
|
|
138
|
+
const buildJobKey = useKey("CNB_BUILD_JOB_KEY");
|
|
139
|
+
const buildWorkspace = useKey("CNB_BUILD_WORKSPACE");
|
|
140
|
+
const buildFailedMsg = useKey("CNB_BUILD_FAILED_MSG");
|
|
141
|
+
const buildFailedStageName = useKey("CNB_BUILD_FAILED_STAGE_NAME");
|
|
142
|
+
const pipelineName = useKey("CNB_PIPELINE_NAME");
|
|
143
|
+
const pipelineKey = useKey("CNB_PIPELINE_KEY");
|
|
144
|
+
const pipelineId = useKey("CNB_PIPELINE_ID");
|
|
145
|
+
const pipelineDockerImage = useKey("CNB_PIPELINE_DOCKER_IMAGE");
|
|
146
|
+
const pipelineStatus = useKey("CNB_PIPELINE_STATUS");
|
|
147
|
+
const pipelineMaxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME");
|
|
148
|
+
const runnerIp = useKey("CNB_RUNNER_IP");
|
|
149
|
+
const cpus = useKey("CNB_CPUS");
|
|
150
|
+
const memory = useKey("CNB_MEMORY");
|
|
151
|
+
const isRetry = useKey("CNB_IS_RETRY");
|
|
152
|
+
const huskySkipInstall = useKey("HUSKY_SKIP_INSTALL");
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
/**
|
|
156
|
+
* @key CNB_BUILD_ID
|
|
157
|
+
* @description:当前构建的流水号,全局唯一
|
|
158
|
+
*/
|
|
159
|
+
buildId,
|
|
160
|
+
/**
|
|
161
|
+
* @key CNB_BUILD_WEB_URL
|
|
162
|
+
* @description:当前构建的日志地址
|
|
163
|
+
*/
|
|
164
|
+
buildWebUrl,
|
|
165
|
+
/**
|
|
166
|
+
* @key CNB_BUILD_START_TIME
|
|
167
|
+
* @description:当前构建的开始时间,UTC 格式
|
|
168
|
+
*/
|
|
169
|
+
buildStartTime,
|
|
170
|
+
/**
|
|
171
|
+
* @key CNB_BUILD_USER
|
|
172
|
+
* @description:当前构建的触发者用户名
|
|
173
|
+
*/
|
|
174
|
+
buildUser,
|
|
175
|
+
/**
|
|
176
|
+
* @key CNB_BUILD_USER_NICKNAME
|
|
177
|
+
* @description:当前构建的触发者昵称
|
|
178
|
+
*/
|
|
179
|
+
buildUserNickname,
|
|
180
|
+
/**
|
|
181
|
+
* @key CNB_BUILD_USER_EMAIL
|
|
182
|
+
* @description:当前构建的触发者邮箱
|
|
183
|
+
*/
|
|
184
|
+
buildUserEmail,
|
|
185
|
+
/**
|
|
186
|
+
* @key CNB_BUILD_USER_ID
|
|
187
|
+
* @description:当前构建的触发者 id
|
|
188
|
+
*/
|
|
189
|
+
buildUserId,
|
|
190
|
+
/**
|
|
191
|
+
* @key CNB_BUILD_USER_NPC_SLUG
|
|
192
|
+
* @description:当前构建若为 NPC 触发,则为 NPC 所属仓库的路径
|
|
193
|
+
*/
|
|
194
|
+
buildUserNpcSlug,
|
|
195
|
+
/**
|
|
196
|
+
* @key CNB_BUILD_USER_NPC_NAME
|
|
197
|
+
* @description:当前构建若为 NPC 触发,则为 NPC 角色名
|
|
198
|
+
*/
|
|
199
|
+
buildUserNpcName,
|
|
200
|
+
/**
|
|
201
|
+
* @key CNB_BUILD_STAGE_NAME
|
|
202
|
+
* @description:当前构建的 stage 名称
|
|
203
|
+
*/
|
|
204
|
+
buildStageName,
|
|
205
|
+
/**
|
|
206
|
+
* @key CNB_BUILD_JOB_NAME
|
|
207
|
+
* @description:当前构建的 job 名称
|
|
208
|
+
*/
|
|
209
|
+
buildJobName,
|
|
210
|
+
/**
|
|
211
|
+
* @key CNB_BUILD_JOB_KEY
|
|
212
|
+
* @description:当前构建的 job key,同 stage 下唯一
|
|
213
|
+
*/
|
|
214
|
+
buildJobKey,
|
|
215
|
+
/**
|
|
216
|
+
* @key CNB_BUILD_WORKSPACE
|
|
217
|
+
* @description:自定义 shell 脚本执行的工作空间根目录
|
|
218
|
+
*/
|
|
219
|
+
buildWorkspace,
|
|
220
|
+
/**
|
|
221
|
+
* @key CNB_BUILD_FAILED_MSG
|
|
222
|
+
* @description:流水线构建失败的错误信息
|
|
223
|
+
*/
|
|
224
|
+
buildFailedMsg,
|
|
225
|
+
/**
|
|
226
|
+
* @key CNB_BUILD_FAILED_STAGE_NAME
|
|
227
|
+
* @description:流水线构建失败的 stage 的名称
|
|
228
|
+
*/
|
|
229
|
+
buildFailedStageName,
|
|
230
|
+
/**
|
|
231
|
+
* @key CNB_PIPELINE_NAME
|
|
232
|
+
* @description:当前 pipeline 的 name
|
|
233
|
+
*/
|
|
234
|
+
pipelineName,
|
|
235
|
+
/**
|
|
236
|
+
* @key CNB_PIPELINE_KEY
|
|
237
|
+
* @description:当前 pipeline 的索引 key
|
|
238
|
+
*/
|
|
239
|
+
pipelineKey,
|
|
240
|
+
/**
|
|
241
|
+
* @key CNB_PIPELINE_ID
|
|
242
|
+
* @description:当前 pipeline 的 id
|
|
243
|
+
*/
|
|
244
|
+
pipelineId,
|
|
245
|
+
/**
|
|
246
|
+
* @key CNB_PIPELINE_DOCKER_IMAGE
|
|
247
|
+
* @description:当前 pipeline 所使用的 docker image
|
|
248
|
+
*/
|
|
249
|
+
pipelineDockerImage,
|
|
250
|
+
/**
|
|
251
|
+
* @key CNB_PIPELINE_STATUS
|
|
252
|
+
* @description:当前流水线的构建状态,可能的值包括:success、error、cancel
|
|
253
|
+
*/
|
|
254
|
+
pipelineStatus,
|
|
255
|
+
/**
|
|
256
|
+
* @key CNB_PIPELINE_MAX_RUN_TIME
|
|
257
|
+
* @description:流水线最大运行时间,单位为毫秒
|
|
258
|
+
*/
|
|
259
|
+
pipelineMaxRunTime,
|
|
260
|
+
/**
|
|
261
|
+
* @key CNB_RUNNER_IP
|
|
262
|
+
* @description:当前 pipeline 所在 Runner 的 ip
|
|
263
|
+
*/
|
|
264
|
+
runnerIp,
|
|
265
|
+
/**
|
|
266
|
+
* @key CNB_CPUS
|
|
267
|
+
* @description:当前构建流水线可以使用的最大 CPU 核数
|
|
268
|
+
*/
|
|
269
|
+
cpus,
|
|
270
|
+
/**
|
|
271
|
+
* @key CNB_MEMORY
|
|
272
|
+
* @description:当前构建流水线可以使用的最大内存大小,单位为 GiB
|
|
273
|
+
*/
|
|
274
|
+
memory,
|
|
275
|
+
/**
|
|
276
|
+
* @key CNB_IS_RETRY
|
|
277
|
+
* @description:当前构建是否由 rebuild 触发
|
|
278
|
+
*/
|
|
279
|
+
isRetry,
|
|
280
|
+
/**
|
|
281
|
+
* @key HUSKY_SKIP_INSTALL
|
|
282
|
+
* @description:兼容 ci 环境下 husky
|
|
283
|
+
*/
|
|
284
|
+
huskySkipInstall
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// CNB_PULL_REQUEST false 对于由 pull_request、pull_request.update、pull_request.target 触发的构建,值为 true,否则为 false
|
|
289
|
+
// CNB_PULL_REQUEST_LIKE false 对于由 合并类事件 触发的构建,值为 true,否则为 false
|
|
290
|
+
// CNB_PULL_REQUEST_PROPOSER 对于由 合并类事件 触发的构建,值为提出 PR 者名称,否则为空字符串
|
|
291
|
+
// CNB_PULL_REQUEST_TITLE 对于由 合并类事件 触发的构建,值为提 PR 时候填写的标题,否则为空字符串
|
|
292
|
+
// CNB_PULL_REQUEST_BRANCH 对于由 合并类事件 触发的构建,值为发起 PR 的源分支名称,否则为空字符串
|
|
293
|
+
// CNB_PULL_REQUEST_SHA 对于由 合并类事件 触发的构建,值为当前 PR 源分支最新的提交 sha,否则为空字符串
|
|
294
|
+
// CNB_PULL_REQUEST_TARGET_SHA 对于由 合并类事件 触发的构建,值为当前 PR 目标分支最新的提交 sha,否则为空字符串
|
|
295
|
+
// CNB_PULL_REQUEST_MERGE_SHA 对于由 pull_request.merged 触发的构建,值为合并后的 sha;对于 pull_request 等触发的构建,值为预合并后的 sha,否则为空字符串
|
|
296
|
+
// CNB_PULL_REQUEST_SLUG 对于由 合并类事件 触发的构建,值为源仓库的仓库 slug,如 group_slug/repo_name,否则为空字符串
|
|
297
|
+
// CNB_PULL_REQUEST_ACTION 对于由 合并类事件 触发的构建,可能的值有:created(新建PR)、code_update(源分支push)、status_update(评审通过或CI状态变更),否则为空字符串
|
|
298
|
+
// CNB_PULL_REQUEST_ID 对于由 合并类事件 触发的构建,值为当前或者关联 PR 的全局唯一 id,否则为空字符串
|
|
299
|
+
export const usePullRequestEnv = () => {
|
|
300
|
+
const pullRequest = useKey("CNB_PULL_REQUEST");
|
|
301
|
+
const pullRequestLike = useKey("CNB_PULL_REQUEST_LIKE");
|
|
302
|
+
const pullRequestProposer = useKey("CNB_PULL_REQUEST_PROPOSER");
|
|
303
|
+
const pullRequestTitle = useKey("CNB_PULL_REQUEST_TITLE");
|
|
304
|
+
const pullRequestBranch = useKey("CNB_PULL_REQUEST_BRANCH");
|
|
305
|
+
const pullRequestSha = useKey("CNB_PULL_REQUEST_SHA");
|
|
306
|
+
const pullRequestTargetSha = useKey("CNB_PULL_REQUEST_TARGET_SHA");
|
|
307
|
+
const pullRequestMergeSha = useKey("CNB_PULL_REQUEST_MERGE_SHA");
|
|
308
|
+
const pullRequestSlug = useKey("CNB_PULL_REQUEST_SLUG");
|
|
309
|
+
const pullRequestAction = useKey("CNB_PULL_REQUEST_ACTION");
|
|
310
|
+
const pullRequestId = useKey("CNB_PULL_REQUEST_ID");
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
/**
|
|
314
|
+
* @key CNB_PULL_REQUEST
|
|
315
|
+
* @description:对于由 pull_request、pull_request.update、pull_request.target 触发的构建,值为 true,否则为 false
|
|
316
|
+
*/
|
|
317
|
+
pullRequest,
|
|
318
|
+
/**
|
|
319
|
+
* @key CNB_PULL_REQUEST_LIKE
|
|
320
|
+
* @description:对于由 合并类事件 触发的构建,值为 true,否则为 false
|
|
321
|
+
*/
|
|
322
|
+
pullRequestLike,
|
|
323
|
+
/**
|
|
324
|
+
* @key CNB_PULL_REQUEST_PROPOSER
|
|
325
|
+
* @description:对于由 合并类事件 触发的构建,值为提出 PR 者名称,否则为空字符串
|
|
326
|
+
*/
|
|
327
|
+
pullRequestProposer,
|
|
328
|
+
/**
|
|
329
|
+
* @key CNB_PULL_REQUEST_TITLE
|
|
330
|
+
* @description:对于由 合并类事件 触发的构建,值为提 PR 时候填写的标题,否则为空字符串
|
|
331
|
+
*/
|
|
332
|
+
pullRequestTitle,
|
|
333
|
+
/**
|
|
334
|
+
* @key CNB_PULL_REQUEST_BRANCH
|
|
335
|
+
* @description:对于由 合并类事件 触发的构建,值为发起 PR 的源分支名称,否则为空字符串
|
|
336
|
+
*/
|
|
337
|
+
pullRequestBranch,
|
|
338
|
+
/**
|
|
339
|
+
* @key CNB_PULL_REQUEST_SHA
|
|
340
|
+
* @description:对于由 合并类事件 触发的构建,值为当前 PR 源分支最新的提交 sha,否则为空字符串
|
|
341
|
+
*/
|
|
342
|
+
pullRequestSha,
|
|
343
|
+
/**
|
|
344
|
+
* @key CNB_PULL_REQUEST_TARGET_SHA
|
|
345
|
+
* @description:对于由 合并类事件 触发的构建,值为当前 PR 目标分支最新的提交 sha,否则为空字符串
|
|
346
|
+
*/
|
|
347
|
+
pullRequestTargetSha,
|
|
348
|
+
/**
|
|
349
|
+
* @key CNB_PULL_REQUEST_MERGE_SHA
|
|
350
|
+
* @description:对于由 pull_request.merged 触发的构建,值为合并后的 sha;对于 pull_request 等触发的构建,值为预合并后的 sha,否则为空字符串
|
|
351
|
+
*/
|
|
352
|
+
pullRequestMergeSha,
|
|
353
|
+
/**
|
|
354
|
+
* @key CNB_PULL_REQUEST_SLUG
|
|
355
|
+
* @description:对于由 合并类事件 触发的构建,值为源仓库的仓库 slug,如 group_slug/repo_name,否则为空字符串
|
|
356
|
+
*/
|
|
357
|
+
pullRequestSlug,
|
|
358
|
+
/**
|
|
359
|
+
* @key CNB_PULL_REQUEST_ACTION
|
|
360
|
+
* @description:对于由 合并类事件 触发的构建,可能的值有:created(新建PR)、code_update(源分支push)、status_update(评审通过或CI状态变更),否则为空字符串
|
|
361
|
+
*/
|
|
362
|
+
pullRequestAction,
|
|
363
|
+
/**
|
|
364
|
+
* @key CNB_PULL_REQUEST_ID
|
|
365
|
+
* @description:对于由 合并类事件 触发的构建,值为当前或者关联 PR 的全局唯一 id,否则为空字符串
|
|
366
|
+
*/
|
|
367
|
+
pullRequestId
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// CNB_REPO_SLUG kevision/dev-cnb 目标仓库路径,格式为 group_slug / repo_name,group_slug / sub_gourp_slug /.../repo_name
|
|
372
|
+
// CNB_REPO_SLUG_LOWERCASE kevision/dev-cnb 目标仓库路径小写格式
|
|
373
|
+
// CNB_REPO_NAME dev-cnb 目标仓库名称
|
|
374
|
+
// CNB_REPO_NAME_LOWERCASE dev-cnb 目标仓库名称小写格式
|
|
375
|
+
// CNB_REPO_ID 2026263219584110592 目标仓库的 id
|
|
376
|
+
// CNB_REPO_URL_HTTPS 目标仓库 https 地址
|
|
377
|
+
export const useRepoInfoEnv = () => {
|
|
378
|
+
const repoSlug = useKey("CNB_REPO_SLUG");
|
|
379
|
+
const repoSlugLowercase = useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
380
|
+
const repoName = useKey("CNB_REPO_NAME");
|
|
381
|
+
const repoNameLowercase = useKey("CNB_REPO_NAME_LOWERCASE");
|
|
382
|
+
const repoId = useKey("CNB_REPO_ID");
|
|
383
|
+
const repoUrlHttps = useKey("CNB_REPO_URL_HTTPS");
|
|
384
|
+
|
|
385
|
+
return {
|
|
386
|
+
/**
|
|
387
|
+
* @key CNB_REPO_SLUG
|
|
388
|
+
* @description:目标仓库路径,格式为 group_slug/repo_name,group_slug/sub_group_slug/.../repo_name
|
|
389
|
+
*/
|
|
390
|
+
repoSlug,
|
|
391
|
+
/**
|
|
392
|
+
* @key CNB_REPO_SLUG_LOWERCASE
|
|
393
|
+
* @description:目标仓库路径小写格式
|
|
394
|
+
*/
|
|
395
|
+
repoSlugLowercase,
|
|
396
|
+
/**
|
|
397
|
+
* @key CNB_REPO_NAME
|
|
398
|
+
* @description:目标仓库名称
|
|
399
|
+
*/
|
|
400
|
+
repoName,
|
|
401
|
+
/**
|
|
402
|
+
* @key CNB_REPO_NAME_LOWERCASE
|
|
403
|
+
* @description:目标仓库名称小写格式
|
|
404
|
+
*/
|
|
405
|
+
repoNameLowercase,
|
|
406
|
+
/**
|
|
407
|
+
* @key CNB_REPO_ID
|
|
408
|
+
* @description:目标仓库的 id
|
|
409
|
+
*/
|
|
410
|
+
repoId,
|
|
411
|
+
/**
|
|
412
|
+
* @key CNB_REPO_URL_HTTPS
|
|
413
|
+
* @description:目标仓库 https 地址
|
|
414
|
+
*/
|
|
415
|
+
repoUrlHttps
|
|
416
|
+
};
|
|
417
|
+
}
|