构建
# 新建构建
请求
POST /openapi/build?projectKey=<项目标识>
1
body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
name | 构建名称 | string | 是 |
project_key | 项目标识 | string | 是 |
infrastructure | 基础设施,kubernetes 为 kubernetes 集群,vm 为主机 | string | 是 |
build_os | 构建操作系统 | string | 是 |
installs | 依赖的软件包 | string | 是 |
script_type | 脚本类型,支持 shell、batch_file、powershell | string | 是 |
build_script | 构建操作系统 | string | 是 |
repo_info | 代码信息 | []RepoInfo | 否 |
parameters | 自定义变量 | []Parameter | 否 |
services | 绑定的服务 | []ServiceWithModule | 是 |
docker_build_step | 镜像构建步骤 | []DockerBuildStep | 否 |
advanced_settings | 高级设置 | []AdvancedSettings | 否 |
ServiceWithModule 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_module | 服务组件名称 | string | 是 |
service_name | 服务名称 | string | 是 |
RepoInfo 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
codehost_name | 代码源标识 | string | 是 |
repo_namespace | 代码库所属命名空间(组织/个人) | string | 是 |
repo_name | 代码库名称 | string | 是 |
branch | 分支信息 | string | 是 |
Parameter 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键值 | string | 是 |
type | 变量的类型,支持 string、choice、multi-select | string | 是 |
is_credential | 是否为敏感信息 | bool | 否 |
description | 变量的描述 | string | 否 |
default_value | 变量的默认值 | string | 是 |
choice_value | 变量的多选值列表 | []string | 否 |
choice_option | 变量的可选值列表 | []string | 否 |
Input 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键值 | string | 是 |
value | 变量的值 | string | 是 |
DockerBuildStep 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
dockerfile_source | Dockerfile 源,local 为代码库,template 为模板库 | string | 是 |
build_context_dir | 构建上下文目录 | string | 是 |
dockerfile_directory | Dockerfile 的绝对路径 | string | 是 |
build_args | 构建参数 | string | 否 |
template_name | 模板名称 | string | 否 |
enable_buildkit | 是否启用 Buildkit | string | 否 |
platforms | Buildkit 构建平台 | string | 否 |
AdvancedSettings 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
cluster_name | 集群名称 | string | 否 |
strategy_name | 调度策略名称 | string | 否 |
timeout | 构建超时时间 | int | 否 |
resource_spec | 集群配置项列表 | ResourceSpec | 否 |
use_host_docker_daemon | 是否使用宿主机docker daemon | bool | 否 |
privileged_mode | 是否启用特权模式 | bool | 否 |
cache_setting | 缓存配置 | CacheSetting | 否 |
storages | 存储配置 | StorageSetting | 否 |
custom_annotations | 自定义注解 | []Input | 否 |
custom_labels | 自定义标签 | []Input | 否 |
outputs | 输出变量 | []string | 否 |
ResourceSpec 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
cpu_req | CPU 请求 | int | 是 |
cpu_limit | CPU 限制 | int | 是 |
memory_req | 内存请求 | int | 是 |
memory_limit | 内存限制 | int | 是 |
gpu_limit | GPU 限制 | string | 否 |
CacheSetting 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
enabled | 是否启用缓存 | bool | 是 |
cache_dir | 缓存目录 | string | 是 |
StorageSetting 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
enabled | 是否启用存储 | bool | 是 |
storages_properties | 存储属性列表 | []StoragesProperty | 是 |
StoragesProperty 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
access_mode | 访问模式,如不设置则默认为 ReadWriteMany,支持 ReadWriteOnce、 ReadOnlyMany、 ReadWriteMany、 ReadWriteOncePod | string | 否 |
is_temporary | 是否为临时存储 | bool | 否 |
mount_path | 挂载路径 | string | 是 |
provision_type | 存储类型,dynmaic 为动态资源,static 为已有存储 | string | 是 |
pvc | PVC名称,provision_type 为 static 时使用该字段 | string | 否 |
storage_class | 存储类名称,provision_type 为 dynamic 时使用该字段 | string | 否 |
storage_size_in_gib | 存储大小,provision_type 为 dynamic 时使用该字段 | int | 是 |
subpath | 存储卷子路径 | string | 是 |
body 参数示例
{
"build_os": "ubuntu 20.04",
"build_script": "#!/bin/bash\nset -e\necho 'hello from api'\ncd $REPONAME_0\nmake build-$SERVICE",
"docker_build_step": {
"build_args": "--build-arg service=$SERVICE",
"build_context_dir": "$REPONAME_0",
"dockerfile_directory": "$REPONAME_0/Dockerfile",
"dockerfile_source": "local",
"enable_buildkit": true,
"platforms": "linux/amd64",
"template_name": ""
},
"infrastructure": "kubernetes",
"installs": [
{
"name": "go",
"version": "1.20.7"
}
],
"name": "api-test",
"parameters": [
{
"choice_option": [
"a",
"b",
"c"
],
"choice_value": [
"a",
"b"
],
"default_value": "a",
"description": "a multi-select var",
"is_credential": false,
"key": "aa",
"type": "multi-select"
},
{
"default_value": "abc123",
"description": "a string values",
"is_credential": true,
"key": "bb",
"type": "string"
}
],
"project_key": "yaml",
"repo_info": [
{
"branch": "main",
"codehost_name": "gitlab",
"repo_name": "multi-service-demo",
"repo_namespace": "kr-test-org1"
}
],
"script_type": "shell",
"services": [
{
"service_module": "service1",
"service_name": "service1"
},
{
"service_module": "service2",
"service_name": "service2"
}
],
"advanced_settings": {
"cache_setting": {
"cache_dir": "$WORKSPACE",
"enabled": true
},
"cluster_name": "local-20250523164625",
"custom_annotations": [
{
"key": "test-a",
"value": "abc"
}
],
"custom_labels": [
{
"key": "test-a",
"value": "abc"
}
],
"outputs": [
"bb"
],
"privileged_mode": false,
"resource_spec": {
"cpu_limit": 1000,
"cpu_req": 100,
"memory_limit": 2000,
"memory_req": 200
},
"storages": {
"enabled": true,
"storages_properties": [
{
"access_mode": "ReadOnlyMany",
"is_temporary": true,
"mount_path": "/workspace",
"provision_type": "dynamic",
"pvc": "share-storage-cfs-10",
"storage_class": "cfs",
"storage_size_in_gib": 2,
"subpath": "$PROJECT"
}
]
},
"strategy_name": "优先调度",
"timeout": 30,
"use_host_docker_daemon": false
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
返回
{
"message": "success"
}
1
2
3
2
3
# 更新构建
请求
PUT /openapi/build?projectKey=<项目标识>
1
body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
name | 构建名称 | string | 是 |
project_key | 项目标识 | string | 是 |
infrastructure | 基础设施,kubernetes 为 kubernetes 集群,vm 为主机 | string | 是 |
build_os | 构建操作系统 | string | 是 |
installs | 依赖的软件包 | string | 是 |
script_type | 脚本类型,支持 shell、batch_file、powershell | string | 是 |
build_script | 构建操作系统 | string | 是 |
repo_info | 代码信息 | []RepoInfo | 否 |
parameters | 自定义变量 | []Parameter | 否 |
services | 绑定的服务 | []ServiceWithModule | 是 |
docker_build_step | 镜像构建步骤 | []DockerBuildStep | 否 |
advanced_settings | 高级设置 | []AdvancedSettings | 否 |
body 参数示例
{
"build_os": "ubuntu 20.04",
"build_script": "#!/bin/bash\nset -e\necho 'hello from api'\ncd $REPONAME_0\nmake build-$SERVICE",
"docker_build_step": {
"build_args": "--build-arg service=$SERVICE",
"build_context_dir": "$REPONAME_0",
"dockerfile_directory": "$REPONAME_0/Dockerfile",
"dockerfile_source": "local",
"enable_buildkit": true,
"platforms": "linux/amd64",
"template_name": ""
},
"infrastructure": "kubernetes",
"installs": [
{
"name": "go",
"version": "1.20.7"
}
],
"name": "api-test",
"parameters": [
{
"choice_option": [
"a",
"b",
"c"
],
"choice_value": [
"a",
"b"
],
"default_value": "a",
"description": "a multi-select var",
"is_credential": false,
"key": "aa",
"type": "multi-select"
},
{
"default_value": "abc123",
"description": "a string values",
"is_credential": true,
"key": "bb",
"type": "string"
}
],
"project_key": "yaml",
"repo_info": [
{
"branch": "main",
"codehost_name": "gitlab",
"repo_name": "multi-service-demo",
"repo_namespace": "kr-test-org1"
}
],
"script_type": "shell",
"services": [
{
"service_module": "service1",
"service_name": "service1"
},
{
"service_module": "service2",
"service_name": "service2"
}
],
"advanced_settings": {
"cache_setting": {
"cache_dir": "$WORKSPACE",
"enabled": true
},
"cluster_name": "local-20250523164625",
"custom_annotations": [
{
"key": "test-a",
"value": "abc"
}
],
"custom_labels": [
{
"key": "test-a",
"value": "abc"
}
],
"outputs": [
"bb"
],
"privileged_mode": false,
"resource_spec": {
"cpu_limit": 1000,
"cpu_req": 100,
"memory_limit": 2000,
"memory_req": 200
},
"storages": {
"enabled": true,
"storages_properties": [
{
"access_mode": "ReadOnlyMany",
"is_temporary": true,
"mount_path": "/workspace",
"provision_type": "dynamic",
"pvc": "share-storage-cfs-10",
"storage_class": "cfs",
"storage_size_in_gib": 2,
"subpath": "$PROJECT"
}
]
},
"strategy_name": "优先调度",
"timeout": 30,
"use_host_docker_daemon": false
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
返回
{
"message": "success"
}
1
2
3
2
3
# 使用模板新建构建
请求
POST /openapi/build?source=template
1
body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
name | 构建名称 | string | 是 |
project_key | 项目标识 | string | 是 |
template_name | 构建模板名称 | string | 是 |
target_services | 服务配置 | []TargetService | 是 |
TargetService 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
service_module | 服务组件名称 | string | 是 |
service_name | 服务名称 | string | 是 |
repo_info | 代码库信息 | []RepoInfo | 是 |
inputs | 变量信息 | []Input | 是 |
RepoInfo 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
codehost_name | 代码源标识 | string | 是 |
repo_namespace | 代码库所属命名空间(组织/个人) | string | 是 |
repo_name | 代码库名称 | string | 是 |
branch | 分支信息 | string | 是 |
Input 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量的键值 | string | 是 |
value | 变量的值 | string | 是 |
body 参数示例
{
"name": "demo-build",
"project_key": "demo",
"template_name": "demo-template",
"target_services": [
{
"service_module": "aslan",
"service_name": "zadigx",
"repo_info": [
{
"codehost_name": "github-demo",
"repo_namespace": "kr-test-org",
"repo_name": "zadig",
"branch": "main"
}
],
"inputs": [
{
"key": "name",
"value": "admin"
},
{
"key": "password",
"value": "zadigx"
}
]
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
返回
{
"message": "success"
}
1
2
3
2
3
# 更新从模版创建的构建
请求
PUT /openapi/build/<构建名称>/template?projectKey=<项目标识>
1
body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
name | 构建名称 | string | 是 |
project_key | 项目标识 | string | 是 |
template_name | 构建模板名称 | string | 是 |
target_services | 服务配置 | []TargetService | 是 |
body 参数示例
{
"name": "demo-build",
"project_key": "demo",
"template_name": "demo-template",
"target_services": [
{
"service_module": "aslan",
"service_name": "zadigx",
"repo_info": [
{
"codehost_name": "github-demo",
"repo_namespace": "kr-test-org",
"repo_name": "zadig",
"branch": "main"
}
],
"inputs": [
{
"key": "name",
"value": "admin"
},
{
"key": "password",
"value": "zadigx"
}
]
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
返回
{
"message": "success"
}
1
2
3
2
3
# 查询构建列表
请求
GET /openapi/build?projectKey=<项目标识>&pageNum=<当前页数>&pageSize=<当前页显示条数>
1
query 参数说明
| 参数名 | 类型 | 描述 | 是否必须 | 默认值 |
|---|---|---|---|---|
projectKey | string | 项目标识 | 是 | 无 |
pageNum | int | 分页参数-当前页数 | 否 | 1 |
pageSize | int | 分页参数-当前页显示条数 | 否 | 20 |
返回说明
| 参数名 | 类型 | 描述 |
|---|---|---|
total | int | 构建模块总数 |
builds | []Build | 构建模块列表 |
Build 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
name | string | 构建名称 |
project_key | string | 项目标识 |
source | string | 构建方式,有以下两种:zadig、jenkins |
update_by | string | 更新者 |
update_time | int | 更新时间 |
target_services | []TargetService | 服务组件列表 |
TargetService 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
service_name | string | 服务名称 |
service_module | string | 服务组件名称 |
正常返回
点击查看
{
"total": 2,
"builds": [
{
"name": "s-build",
"project_key": "lilian-test",
"source": "zadig",
"update_by": "admin",
"update_time": 1686192895,
"target_services": [
{
"service_name": "service1",
"service_module": "service1"
},
{
"service_name": "service2",
"service_module": "service2"
}
]
},
{
"name": "openapi-build",
"project_key": "lilian-test",
"source": "zadig",
"update_by": "admin",
"update_time": 1688040721,
"target_services": [
{
"service_name": "service1",
"service_module": "service1"
}
]
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 获取构建详情
请求
GET /openapi/build/:buildName/detail?projectKey=<项目标识>
1
query 参数说明
| 参数名 | 类型 | 描述 | 是否必须 | 默认值 |
|---|---|---|---|---|
projectKey | string | 项目标识 | 是 | 无 |
serviceName | string | 服务名称 | 是 | 无 |
serviceModule | string | 服务组件名称 | 是 | 无 |
路径参数说明
| 参数名 | 类型 | 描述 | 是否必须 | 默认值 |
|---|---|---|---|---|
buildName | string | 构建名称 | 是 | 无 |
返回说明
点击查看
{
"project_key": "lilian-test", // 项目标识
"name": "openapi-build", // 构建名称
"source": "", // 构建方式,分别有 zadig,jenkins两种
"target_services": [ // 服务列表
{
"service_name": "service1", // 服务名称
"service_module": "service1" // 服务组件名称
}
],
"template_name": "test", // 模板名称
"update_by": "admin", // 更新的用户名称
"update_time": 1690215924, // 更新时间,秒级时间戳
"repos": [ // 代码源信息
{
"source": "gitee", // 有以下几种类型:github、gitlab、gerrit、codehub、gitee、gitee-enterprise、other
"repo_owner": "liyue326", // 组织名/用户名
"repo_name": "hello", // 代码库名称
"remote_name": "origin", // Remote name
"branch": "master", // 分支名称
"address":"https://gitlab.com", // 代码源
"checkout_path":"", // 克隆目录名
"submodules":false, // 子模块
},
],
"build_env": { // 构建环境
"basic_image_id": "63047770931401b9baa6e396", // 操作系统镜像ID
"basic_image_label": "ubuntu 20.04", // 操作系统镜像名称
"installs": [ // 构建依赖的软件包列表
{
"name": "go",
"version": "1.13"
}
]
},
"advanced_settings": { // 高级配置
"cluster_name": "local-20220823144517", // 集群名称
"timeout": 60, // 构建超时时间
"resource_spec": { // 集群配置项列表
"cpu_limit": 1000,
"memory_limit": 512,
"gpu_limit": ""
},
"use_host_docker_daemon": false, // 是否使用宿主机docker daemon
"cache_setting": { // 缓存配置
"enabled": false, // 是否使用自定义工作空间
"cache_dir": "" // 自定义工作流空间下的缓存路径
}
},
"build_script": "#!/bin/bash\nset -e", // 构建脚本
"parameters": [ // 自定义变量列表
{
"key": "a",
"value": "1",
"type": "string",
"is_credential": false
}
]
"outputs": [ // 输出变量列表
{
"name": "IMAGE",
"description": ""
},
{
"name": "PKG_FILE",
"description": ""
},
{
"name": "xx",
"description": ""
}
],
"post_build": { // 添加步骤
"docker_build": { // 镜像构建配置
"work_dir": "temp", // 构建上下文目录
"docker_file": "temp", // Dockerfile 的绝对路径
"build_args": "", // 构建参数
"source": "local", // Dockerfile 来源
"template_name": "" // template名称(如果dockerfile来源是模板)
},
"object_storage_upload": { // 文件存储
"enabled": true, // 是否使用工作空间缓存
"object_storage_id": "63422e0690069fe35f4e62bb", // sidebarMenu.objectStorage
"upload_detail": [ // 上传文件配置
{
"file_path": "test",
"abs_file_path": "",
"dest_path": "temp"
}
]
},
"file_archive": { // 二进制包存储
"file_location": "temp" // 二进制包存储路径
},
"scripts": "#!/bin/bash\nset -e" // Shell 脚本
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# 删除构建
请求
DELETE /openapi/build?name=<构建名称>&projectKey=<项目标识>
1
query 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
name | 构建名称 | string | 是 |
projectKey | 项目标识 | string | 是 |
返回说明
{
"message": "success"
}
1
2
3
2
3


