Zadig 文档
Zadig
教程
博客
论坛
关于
中文英文
Zadig
教程
博客
论坛
关于
Zadig v4.2
Loading...
     编辑文档
     反馈问题
     社区讨论

    本页导航

    Build

    # Create Build

    Request

    POST /openapi/build?projectKey=<project identifier>
    
    1

    Body Parameters

    Parameter NameDescriptionTypeRequired
    nameBuild namestringYes
    project_keyProject identifierstringYes
    infrastructureInfrastructure, kubernetes for kubernetes cluster, vm for hoststringYes
    build_osBuild operating systemstringYes
    installsDependent software packagesstringYes
    script_typeScript type, supports shell, batch_file, powershellstringYes
    build_scriptBuild operating systemstringYes
    repo_infoCode information[]RepoInfoNo
    parametersCustom variables[]ParameterNo
    servicesBound services[]ServiceWithModuleYes
    docker_build_stepImage build step[]DockerBuildStepNo
    advanced_settingsAdvanced settings[]AdvancedSettingsNo

    ServiceWithModule Parameters

    Parameter NameDescriptionTypeRequired
    service_moduleService module namestringYes
    service_nameService namestringYes

    RepoInfo Parameters

    Parameter NameDescriptionTypeRequired
    codehost_nameCode source identifierstringYes
    repo_namespaceRepository namespace (organization/user)stringYes
    repo_nameRepository namestringYes
    branchBranch informationstringYes

    Parameter Parameters

    Parameter NameDescriptionTypeRequired
    keyVariable keystringYes
    typeVariable type, supports string, choice, multi-selectstringYes
    is_credentialIs sensitive informationboolNo
    descriptionVariable descriptionstringNo
    default_valueVariable default valuestringYes
    choice_valueVariable multi-select value list[]stringNo
    choice_optionVariable optional value list[]stringNo

    Input Parameters

    Parameter NameDescriptionTypeRequired
    keyVariable keystringYes
    valueVariable valuestringYes

    DockerBuildStep Parameters

    Parameter NameDescriptionTypeRequired
    dockerfile_sourceDockerfile source, local for code repository, template for template librarystringYes
    build_context_dirBuild context directorystringYes
    dockerfile_directoryDockerfile absolute pathstringYes
    build_argsBuild argumentsstringNo
    template_nameTemplate namestringNo
    enable_buildkitEnable BuildkitstringNo
    platformsBuildkit build platformstringNo

    AdvancedSettings Parameters

    Parameter NameDescriptionTypeRequired
    cluster_nameCluster namestringNo
    strategy_nameScheduling strategy namestringNo
    timeoutBuild timeout timeintNo
    resource_specCluster configuration item listResourceSpecNo
    use_host_docker_daemonUse host docker daemonboolNo
    privileged_modeEnable privileged modeboolNo
    cache_settingCache configurationCacheSettingNo
    storagesStorage configurationStorageSettingNo
    custom_annotationsCustom annotations[]InputNo
    custom_labelsCustom labels[]InputNo
    outputsOutput variables[]stringNo

    ResourceSpec Parameters

    Parameter NameDescriptionTypeRequired
    cpu_reqCPU requestintYes
    cpu_limitCPU limitintYes
    memory_reqMemory requestintYes
    memory_limitMemory limitintYes
    gpu_limitGPU limitstringNo

    CacheSetting Parameters

    Parameter NameDescriptionTypeRequired
    enabledEnable cacheboolYes
    cache_dirCache directorystringYes

    StorageSetting Parameters

    Parameter NameDescriptionTypeRequired
    enabledEnable storageboolYes
    storages_propertiesStorage property list[]StoragesPropertyYes

    StoragesProperty Parameters

    Parameter NameDescriptionTypeRequired
    access_modeAccess mode, if not set, defaults to ReadWriteMany, supports ReadWriteOnce, ReadOnlyMany, ReadWriteMany, ReadWriteOncePodstringNo
    is_temporaryIs temporary storageboolNo
    mount_pathMount pathstringYes
    provision_typeStorage type, dynamic for dynamic resource, static for existing storagestringYes
    pvcPVC name, used when provision_type is staticstringNo
    storage_classStorage class name, used when provision_type is dynamicstringNo
    storage_size_in_gibStorage size, used when provision_type is dynamicintYes
    subpathStorage volume subpathstringYes

    Body Parameter Example

    {
        "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

    Response

    {
      "message": "success"
    }
    
    1
    2
    3

    # Update Build

    Request

    PUT /openapi/build?projectKey=<project identifier>
    
    1

    Body Parameters

    Parameter NameDescriptionTypeRequired
    nameBuild namestringYes
    project_keyProject identifierstringYes
    infrastructureInfrastructure, kubernetes for kubernetes cluster, vm for hoststringYes
    build_osBuild operating systemstringYes
    installsDependent software packagesstringYes
    script_typeScript type, supports shell, batch_file, powershellstringYes
    build_scriptBuild operating systemstringYes
    repo_infoCode information[]RepoInfoNo
    parametersCustom variables[]ParameterNo
    servicesBound services[]ServiceWithModuleYes
    docker_build_stepImage build step[]DockerBuildStepNo
    advanced_settingsAdvanced settings[]AdvancedSettingsNo

    Body Parameter Example

    {
        "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

    Response

    {
      "message": "success"
    }
    
    1
    2
    3

    # Create Build from Template

    Request

    POST /openapi/build?source=template
    
    1

    Body Parameter Description

    Parameter NameDescriptionTypeRequired
    nameBuild namestringYes
    project_keyProject identifierstringYes
    template_nameBuild template namestringYes
    target_servicesService configuration[]TargetServiceYes

    TargetService Parameter Description

    Parameter NameDescriptionTypeRequired
    service_moduleService module namestringYes
    service_nameService namestringYes
    repo_infoRepository info[]RepoInfoYes
    inputsVariable info[]InputYes

    RepoInfo Parameter Description

    Parameter NameDescriptionTypeRequired
    codehost_nameCode source identifierstringYes
    repo_namespaceRepository namespace (organization/user)stringYes
    repo_nameRepository namestringYes
    branchBranch informationstringYes

    Input Parameter Description

    Parameter NameDescriptionTypeRequired
    keyVariable keystringYes
    valueVariable valuestringYes

    Body Parameter Example

    {
        "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

    Return

    {
      "message": "success"
    }
    
    1
    2
    3

    # Update Build from Template

    Request

    PUT /openapi/build/<build name>/template?projectKey=<project identifier>
    
    1

    Body Parameters

    Parameter NameDescriptionTypeRequired
    nameBuild namestringYes
    project_keyProject identifierstringYes
    template_nameBuild template namestringYes
    target_servicesService configuration[]TargetServiceYes

    Body Parameter Example

    {
        "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

    Return

    {
      "message": "success"
    }
    
    1
    2
    3

    # Query Build List

    Request

    GET /openapi/build?projectKey=<project identifier>&pageNum=<current page number>&pageSize=<current page display count>
    
    1

    Query Parameter Description

    Parameter NameTypeDescriptionRequiredDefault Value
    projectKeystringProject identifierYesNone
    pageNumintPage parameter-current page numberNo1
    pageSizeintPage parameter-current page display countNo20

    Return Description

    Parameter NameTypeDescription
    totalintBuild module total number
    builds[]BuildBuild module list

    Build Parameter Description

    Parameter NameTypeDescription
    namestringBuild name
    project_keystringProject identifier
    sourcestringBuild method, there are two: zadig, jenkins
    update_bystringUpdater
    update_timeintUpdate time
    target_services[]TargetServiceService component list

    TargetService Parameter Description

    Parameter NameTypeDescription
    service_namestringService name
    service_modulestringService component name

    Normal Return

    Details
    {
        "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

    # Get Build Details

    Request

    GET /openapi/build/:buildName/detail?projectKey=<project identifier>
    
    1

    Query Parameter Description

    Parameter NameTypeDescriptionRequiredDefault Value
    projectKeystringProject identifierYesNone
    serviceNamestringService nameYesNone
    serviceModulestringService component nameYesNone

    Path Parameter Description

    Parameter NameTypeDescriptionRequiredDefault Value
    buildNamestringBuild nameYesNone

    Return Description

    Details
    {
        "project_key": "lilian-test", // Project identifier
        "name": "openapi-build", // Build name
        "source": "",	// Build method, there are two: zadig,jenkins
        "target_services": [	// Service list
            {
                "service_name": "service1", // Service name
                "service_module": "service1" // Service component name
            }
        ],
        "template_name": "test", // Template name
        "update_by": "admin",	// Updater name
        "update_time": 1690215924, // Update time, second level timestamp
        "repos": [ // Repository information
          {
                "source": "gitee", // There are several types: github, gitlab, gerrit, codehub, gitee, gitee-enterprise, other
                "repo_owner": "liyue326",	// Organization name/user name
                "repo_name": "hello",	// Repository name
                "remote_name": "origin", // Remote name
                "branch": "master",	// Branch name
            		"address":"https://gitlab.com",	// Repository source
            		"checkout_path":"", // Clone directory name
            		"submodules":false,	 // Submodule
            },
        ],
        "build_env": { // Build environment
            "basic_image_id": "63047770931401b9baa6e396",	// Operating system image ID
            "basic_image_label": "ubuntu 20.04",	// Operating system image name
            "installs": [	// Build dependent software package list
                {
                    "name": "go",
                    "version": "1.13"
                }
            ]
        },
        "advanced_settings": { // Advanced configuration
            "cluster_name": "local-20220823144517",	// Cluster name
            "timeout": 60,	// Build timeout time
            "resource_spec": {	// Cluster configuration item list
                "cpu_limit": 1000,
                "memory_limit": 512,
                "gpu_limit": ""
            },
          	"use_host_docker_daemon": false, // Whether to use host docker daemon
            "cache_setting": {	// Cache configuration
                "enabled": false,	// Whether to use custom workspace
                "cache_dir": ""	// Cache path under custom workspace
            }
        },
        "build_script": "#!/bin/bash\nset -e",	// Build script
        "parameters": [	// Custom variable list
            {
                "key": "a",
                "value": "1",
                "type": "string",
                "is_credential": false
            }
        ],
        "outputs": [	// Output variable list
            {
                "name": "IMAGE",
                "description": ""
            },
            {
                "name": "PKG_FILE",
                "description": ""
            },
            {
                "name": "xx",
                "description": ""
            }
        ],
        "post_build": {	// Add step
            "docker_build": {	// Image build configuration
                "work_dir": "temp",	// Build context directory
                "docker_file": "temp",	// Absolute path of Dockerfile
                "build_args": "",	// Build parameter
                "source": "local",	// Dockerfile source
                "template_name": ""	// template name (if dockerfile source is template)
            },
            "object_storage_upload": {	// File storage
                "enabled": true,	// Whether to use workspace cache
                "object_storage_id": "63422e0690069fe35f4e62bb",	// sidebarMenu.objectStorage
                "upload_detail": [	// Upload file configuration
                    {
                        "file_path": "test",
                        "abs_file_path": "",
                        "dest_path": "temp"
                    }
                ]
            },
            "file_archive": {	// Binary package storage
                "file_location": "temp"	// Binary package storage path
            },
            "scripts": "#!/bin/bash\nset -e"	// Shell script
        }
    }
    
    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

    # Delete Build

    Request

    DELETE /openapi/build?name=<build name>&projectKey=<project identifier>
    
    1

    Query Parameter Description

    Parameter NameDescriptionTypeRequired
    nameBuild namestringYes
    projectKeyProject identifierstringYes

    Return Description

    {
      "message": "success"
    }
    
    1
    2
    3

    ← ServiceTest→

    资源
    教程
    论坛
    博客
    公司
    关于
    客户故事
    加入我们
    联系我们
    微信扫一扫
    hello@koderover.com

    © 2026 筑栈(上海)信息技术有限公司 沪 ICP 备 19000177 号 - 1

    •  跟随系统
    •  浅色模式
    •  深色模式
    •  阅读模式