Crafting Your build.xml for a Single Task
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 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 details about the YAML file structure of multiple tasks, see Crafting Your build.xml 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" |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot