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

Crafting Your build.yml for a Single Task

The following example uses a built-in x86 executor with 8 vCPUs and 16 GB memory. The build task retrieves source code from CodeArts Repo, compiles and builds the code with Maven, and then uploads the generated software package to a release repo.

For details about how to define build actions with code, navigate Configuring a Build Task > "Performing Basic Configurations" > "Configure Build Actions", locate your desired actions, and examine the sample code under "Build with Code". For guidance on defining multiple tasks with YAML, see Crafting Your build.yml for Multiple Tasks.

 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
version: 2.0 # Define the version number. It is required and must be set to 2.0.
params: # Declare parameters that can be referenced during build processes. If you leave this section unspecified, any parameters defined during task configuration take precedence.
  - name: paramA
    value: valueA
  - name: paramB
    value: valueB
env: # Define the build environment. It is optional and defaults to x86 environment if unspecified.
  resource:
    type: docker # Specify the agent pool type. The value can be docker or custom. Set this value to docker to run your build on a default executor, or choose custom when using a custom executor.
    arch: X86 # Specify the host architecture for the build environment. Select either x86 or Arm.
    class: 8U16G # Define the specification, which can be 2U8G (2 vCPUs | 8 GB), 4U8G (4 vCPUs | 8 GB), 8U16G (8 vCPUs | 16 GB), 16U32G (16 vCPUs | 32 GB), or 16U64G (16 vCPUs | 64 GB). This parameter is not required when type is set to custom.
    pool: Mydocker #Set the agent pool name. This parameter is required when type is set to custom.
steps:
  PRE_BUILD: # This phase makes build preparations, such as downloading code and running shell commands.
    - checkout:
        name: Code download # Optional
        inputs: # Action parameters
          scm: codehub # Code source: CodeArts Repo only
          url: xxxxxxxxx # Set the SSH address of the repository from which the code is pulled.
          branch: ${codeBranch} # Identify the branch from which the code is pulled. This value can be parameterized.
    - sh:
        inputs:
          command: echo ${paramA}
  BUILD: # Define build actions. Only one BUILD can be configured.
    - maven: # Action keyword. Only specific keywords are supported.
	name: maven build # Optional
	image: xxx # Image address
	inputs:
	  command: mvn clean package
    - upload_artifact:
	inputs:
          path: "**/target/*.?ar"