Updated on 2025-06-09 GMT+08:00

Creating the build.xml File for a Single Task

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.

The following example uses a built-in x86 executor with 8 vCPUs and 16 GB memory. The tasks involve compiling and building code from CodeArts Repo using Maven, and then uploading the resulting software package to a release repo.

For details about the sample code of different build actions, see the "Build as Code" part of each build action in Configuring Build Actions. For details about the YAML file structure of multiple tasks, see Creating the build.xml File 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 # The version number is a mandatory and unique parameter that must be set to 2.0.
params: # Build parameters that can be referenced during your build. If no build parameters are set here, parameters created during task configuration are preferentially used.
  - name: paramA
    value: valueA
  - name: paramB
    value: valueB
env: # Optional. It defines the build environment. x86 is used by default if neither env or envs is set.
  resource:
    type: docker # Agent pool type. The value can be docker or custom. docker indicates that the default executor is used, and custom indicates that a custom executor is used.
    arch: X86 # The host type of the build environment can be either x86 or Arm.
    class: 8 vCPUs | 16 GB # The specification can be: 2 vCPUs | 8 GB, 4 vCPUs | 8 GB, 8 vCPUs | 16 GB, 16 vCPUs | 32 GB, or 16 vCPUs | 64 GB. This parameter is not required when the agent pool type is set to a custom one.
    pool: Mydocker #Agent pool name. This parameter is required when the agent pool type is set to a custom one.
steps:
  PRE_BUILD: # It prepares for the build process by performing tasks 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 # This refers to the SSH address of the repository that the code is pulled from.
          branch: ${codeBranch} # Pulled code branch, which can be parameterized.
    - sh:
        inputs:
          command: echo ${paramA}
  BUILD: # It defines the build action. Only one BUILD can be configured.
    - maven: # Action keyword. Only specified keywords are supported.
	name: maven build # Optional
	image: xxx # Image address.
	inputs:
	  command: mvn clean package
    - upload_artifact:
	inputs:
          path: "**/target/*.?ar"