Updated on 2026-02-11 GMT+08:00

Creating a Build Task with Code

CodeArts Build allows you to define your build as code using YAML. Your configurations, such as build environments, parameters, commands, and actions, reside in a YAML file named build.yml. After creating this file, add it along with the source code to a code repository. The file will be used as a script by the system to run a build.

Constraints

You can only use the code hosted in CodeArts Repo for YAML builds.

Preparations

Creating a YAML File for Your Code-based Build

  1. Access the CodeArts Build homepage from the project page.
  2. In the navigation pane, choose Code > Repo. Create a code repository by referring to Creating a Custom Repository.
  3. Click the repository name. On the displayed page, choose Create > Create Directory and name the directory .cloudbuild.
  4. In the .cloudbuild directory, choose Create > Create File to create a file named build.yml. Figure 1 shows the directory that stores files of the code repository.
    Figure 1 Directory

    If the YAML file is not stored in the .cloudbuild directory, you can use parameter CB_BUILD_YAML_PATH to specify the path of the YAML file in the code repository. For details about parameter settings, see Adding Custom Parameters.

  5. Click and write the build.yml file by referring to the sample code in Crafting Your build.yml for a Single Task or Crafting Your build.yml for Multiple Tasks.

Configuring Basic Information

  1. In the navigation pane, choose CICD > Build.
  2. Click Create Task. On the displayed Basic Information page, configure the essential attributes for your build task. For details, see Table 1.
    Table 1 Basic information

    Parameter

    Description

    Name

    Assign a custom name to the build task.

    • Letters, digits, underscores (_), and hyphens (-) allowed.
    • 1 to 115 characters.

    Project

    Select the project to which the build task belongs.

    • When you access CodeArts Build through the project page, this parameter is autofilled so you can leave it as default.
    • When accessing the service through the service homepage, select the project created in Preparations.

    Code Source

    If you select Repo, code is pulled from CodeArts Repo for your build.

    Repository

    Select the exact repository from which CodeArts Build retrieves the code to compile.

    Default Branch

    Select a default branch.

    Description

    Optional. Enter additional information to describe the build task. Max. 512 characters.

  3. Click Next. The page for selecting a build template is displayed.

Selecting a Build Template

  1. Keep the default template selected.

    No matter which build template you select, YAML builds remain unaffected.

  2. Click OK. The Build Actions page is displayed.

Configuring Build Actions

On the Build Actions page, click the Code tab in the upper left corner. The system automatically reads the YAML file from the code repository and the branch configured in basic information.

You can modify the YAML file by referring to the sample code. For details, navigate Configuring a Build Task > "Performing Basic Configurations" > "Configuring Build Actions", locate your desired actions, and examine the sample code under "Build with Code". Once the build task is completed, any changes made to the YAML file on this page will overwrite the original YAML file you create for your code-based build.

Complete all configurations and click Save to create a build task. The new task appears in the build task list.