Build Configuration
Zadig build supports operations such as pulling code, compiling code, building Docker images/APK packages/Tar packages, pushing images, and uploading to object storage. It comes with common build environments and software packages and supports build caching.

- Supports configuring multiple builds for a service, and select on demand in the workflow configuration. For more details, please refer to Workflow - Build task configuration
- It supports multiple services using the same build configuration. For more details, please refer to Shared Build
- Supports modifying the generation rules for building deliverables. For more details, please refer to Build deliverable generation rules
Preparation
Clearly identify the dependencies required for the build, including but not limited to:
- Service compilation code dependencies (such as dependencies on Base libraries, open-source libraries, etc.)
- Service compilation environment dependencies (such as Go version, Node version, compilation tools, etc.)
- Service compilation system dependencies (such as operating systems, etc.)
# Basic Configuration

Parameter Description:
Build Name: Customize it to be meaningful and easy to understandService Selection: Select the service to use this build configuration
# Build Environment
Configure the environment for the build process, supporting both Kubernetes and host infrastructure.

# Using Kubernetes
The build process runs in a K8s Pod, and you can configure operating system and software package dependencies.
Operating System: The platform provides by default Ubuntu 18.04 / Ubuntu 20.04 as the basic build system, it supports adding custom images as the build operating system, refer to Build image managementDependencies Software Package: Various software package tools needed during the build process, such as different versions of Java, Go, Govendor, Node, Bower, Yarn, Phantomjs, etc.
Tip
- The default Ubuntu series build systems provided by the platform already support the following tools/commands, which can be used directly in Software Package Management and build scripts:
- build-essential / cmake / curl / docker / git
- libfontconfig / libfreetype6-dev / libpcre3-dev / librrd-dev / libsasl2-dev
- netcat-openbsd / pkg-config / python / tar / wget
- When selecting software packages, pay attention to the installation dependencies. The system will install them in the order of selection. For example: Govendor depends on Go, so please select Go first, then Govendor
- The platform has already built in some common software packages. If there are other software packages or version requirements, the system administrator can configure their installation scripts in Software Package Management
# Using Host
Execute build steps on the selected host, and the required software, tools, etc., can be installed in advance on the host.
# Code Information

Parameter Description:
Code Source: The platform where the code base is located. Please refer to Code Source Information for supported code sourcesCode Repository Owner: Supports configuring all code repository owners under integrated code sourcesCode Repository Name: The name of the code repositoryDefault Branch: The default branch selected when executing workflow configuration build variables, which can be modified during executionRemote name: Specifies the name of the remote code repository, defaultoriginClone Directory Name: Defines the directory name after the code repository is cloned, defaulting to the name of the code repositorySubmodule: Synchronizes the code repositories configured insubmodulePull Specific Commit: When enabled, supports selecting a specific Commit to execute when running the workflowDisplay when executing: On by default. If set to off, the code repository option will not be displayed when executing the workflow, and the code configuration will use the default value
The working directory structure is as follows:
├── $WORKSPACE # The root directory of the build task
├── repository 1 # The first code repository
├── repository 2 # The second code repository
├── code # The code in the second code repository
└── ...
└── ...
2
3
4
5
6
Where:
$WORKSPACEis the built-in variable of the Zadig system build module, for a more detailed description, refer to System built-in environment variables
# Build Variables
Includes both system-built-in build variables and user-defined build variables, which can be used directly in the build script.
Tip: Add
envcommands to Build script to view all build variables.

Built-in Build Variables
Built-in variables and their descriptions are as follows:
| Variable Name | Description |
|---|---|
WORKSPACE | Current workflow working directory |
WORKFLOW | Workflow ID for executing the build |
PROJECT | Project ID |
TASK_ID | The ID of the current workflow task, i.e., the task sequence number |
IMAGE | The image name generated by the system according to the built-in rules is used for deployment updates of container services. The naming rules can be modified in the service's Policy configuration |
PKG_FILE | The system can modify the naming rules of the delivery file name generated by the built-in rules, and can modify its naming rules in the service's Policy configuration |
SERVICE_NAME | The name of the built service |
SERVICE_MODULE | The name of the built service component |
TASK_URL | The URL of the build task |
CI | The value is always true and can be used as needed, such as to determine if it is a CI script or another script |
Zadig | The value is always true and can be used as needed, such as to determine if it is being executed in the Zadig system |
REPONAME_<index> | 1. Get the code repository name of the specified <index>2. <index> is the position of the code in the build configuration, with an initial value of 03. In the following example, using $REPO_0 in the build script will get the name of the first code repository voting-app |
REPO_<index> | 1. Get the code repository name of the specified <index> and automatically replace the hyphen - in the name with an underscore _2. <index> is the position of the code in the build configuration, with an initial value of 03. In the following example, using $REPO_0 in the build script will get the converted name of the first code repository voting_app |
<REPO>_PR | 1. Get the Pull Request information used for the specified <REPO> during the build process. When using, please replace <REPO> with the specific code repository name2. When the <REPO> information contains a hyphen -, replace - with an underscore _3. In the following example, to get the Pull Request information for the voting-app repository, use $voting_app_PR or eval PR=\${${REPO_0}_PR}4. If multiple PRs are specified during the build, such as PR IDs 1, 2, 3, the value of the variable will be 1,2,35. When the code repository is from the other code source, this variable is not supported |
<REPO>_BRANCH | 1. Get the branch information used for the specified <REPO> during the build process. When using, please replace <REPO> with the specific code repository name2. When the <REPO> information contains a hyphen -, replace - with an underscore _3. In the following example, to get the branch information for the voting-app repository, use $voting_app_BRANCH or eval BRANCH=\${${REPO_0}_BRANCH} |
<REPO>_PRE_MERGE_BRANCHES | 1. Pre-merge branches when running multi-branch merge builds; <REPO> is the specific repository name and can be provided directly or combined with the $<REPO_INDEX> variable2. If <REPO> contains a hyphen -, replace it with an underscore _3. For example, use eval BRANCH=\${${REPO_0}_PRE_MERGE_BRANCHES} to get the pre-merge branch info for the first repository |
<REPO>_TAG | 1. Get the Tag information used for the specified <REPO> during the build process. When using, please replace <REPO> with the specific code repository name2. When the <REPO> information contains a hyphen -, replace - with an underscore _3. In the following example, to get the Tag information for the voting-app repository, use $voting_app_TAG or eval TAG=\${${REPO_0}_TAG} |
<REPO>_COMMIT_ID | 1. Get the Commit ID information used for the specified <REPO> during the build process. When using, please replace <REPO> with the specific code repository name2. When the <REPO> information contains a hyphen -, replace - with an underscore _3. In the following example, to get the Commit ID information for the voting-app repository, use $voting_app_COMMIT_ID or eval COMMIT_ID=\${${REPO_0}_COMMIT_ID}4. When the code repository is from the other code source, this variable is not supported |
<REPO>_ORG | 1. Get the organization/user information used for the specified <REPO> during the test process. When using, please replace <REPO> with the specific code repository name2. When the <REPO> information contains a hyphen -, replace - with an underscore _3. In the following example, to get the organization/user information for the voting-app repository, use $voting_app_ORG or eval ORG=\${${REPO_0}_ORG} |

Custom Build Variables
Explanation:
- Supports string (single-line/multi-line), single-choice, multiple-choice, file, and dynamic variable types
- You can set string-type variables as sensitive information, and the value of sensitive variables will not be output in the build log of the workflow task
- When executing workflow tasks, you can modify the values of custom build variables to override the default values configured here, as shown in the figure below:

# Build Script
Declare the build process and implementation in the build script.
Build variables can be used in build scripts

# Advanced Configuration

Explanation:
Policy Configuration: Configure the timeout time for the build service. If the build is not successful after the set time threshold, it will be considered a timeout failureCache Configuration: After caching is enabled, the cache directory configured here will be used when the workflow is executed. The directory configuration can use Build variablesCluster Selection: Select the cluster resource to be used when the build task runs, where the local cluster refers to the cluster where the Zadig system is located. For cluster integration, refer to Cluster ManagementOperating System Specification: Configure resource specifications for performing build tasks. The platform provides four configurations for High/Medium/Low/Lowest. In addition, you can also customize according to actual needs. If you need to use GPU resource, resource configuration form isvendorname.com/gpu:num, please refer to Scheduling GPU(opens new window) for more informationScheduling Policy: Select the cluster scheduling policy, and the default isRandom Schedulingpolicy. Please refer to Set scheduling policy managementMount Storage: Mount persistent storage for build tasks, supports configuring storage type, storage size and mount path, can be used for storing build artifacts and other scenariosUse Host Docker daemon: After enabling, the Docker daemon on the node where the container is located will be used during the build execution process to perform Docker operationsPrivileged: After enabling, the container in the Pod will run in privileged mode. This is suitable for build scenarios that require running Docker inside the container or need higher system permissions. Note: Privileged mode has certain security risks and is only recommended in trusted environmentsTask Labels: Configure the Pod resource tags for the build task executionTask Annotations: Configure the Pod resource annotations for the build task executionOutput Variables: Output the environment variables in the build, which can realize the variable transfer between different tasks in the workflow, refer to Variable passing
# More Build Steps
In Add Steps, you can add more build steps as needed.

Image Building
Build the image according to the configured parameters, using the built-in variable
IMAGEas the name of the built image, and push it to the image repository.
Parameter Description:
Build Context Directory: The directory where the execution docker build is locatedDockerfile Source: IncludesCode RepositoryandTemplate Library. For more information on the template library, see Dockerfile Template ManagementDockerfile Absolute Path: When Dockerfile originates from the code base, specify the Dockerfile path used to execute docker buildTemplate Selection: When the Dockerfile originates from the template library, select the specific Dockerfile templateBuild Parameters: All parameters that support docker build, such as:--build-arg key1=value1 --build-arg key2=value2BuildKit Build: After enabling, supports multi-platform builds, improving build efficiency and compatibility.
Among the above parameters, except Dockerfile Source and Template Selection, Variables can be used for all other parameters.
Binary Package Storage
Configure the storage path for the built binary package.
File Storage
Upload the specified file to the object storage. After uploading, the file will be stored in the specified directory of the corresponding bucket in the object storage. The directory here can use Variables, but it does not support nested variables, such as ${$REPO_0}_BRANCH.
- Upload specified file: configure the specified file path, such as
infra/result.xmlin the figure above - Upload all files in the directory (excluding subdirectories): configure the specified directory, such as
infra/examples/in the figure above
Shell Script Execution
Add a Shell script execution step to perform certain operations after the build.


