Updated on 2025-08-06 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 code-based builds.

Preparations

Creating a YAML File for Your Code-based Build

  1. Access the CodeArts Build homepage from the project list.
  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.xml for a Single Task or Crafting Your build.xml for Multiple Tasks.

Configuring Basic Information

  1. In the navigation pane, choose CICD > Build.
  2. Click Create Task. On the displayed page, configure the basic information of the build task by referring to 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.

    • This parameter is autofilled when you access CodeArts Build through the project list, 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 repository from where the code to be compiled is pulled.

    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, code-based builds remain unaffected.

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

Configuring Build Actions

In the upper left corner of the Build Actions page, click the Code tab. 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 in sections "Performing Basic Configurations" and "Configuring Build Actions" of Configuring a Build Task. Any changes made to the YAML file will overwrite the original YAML file you create for your code-based build once the build task is completed.

Complete all the configurations and click Save to create a build task. The new task will be displayed on the build task list.