このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。
Syntax Guide to YAML File Configuration
Sample Code for Single-task Build
--- version: 2.0 #Parameters are specified in pairs, with a name and a corresponding value. If no value is assigned to a parameter, it will default to an empty string. When referencing a parameter, use the syntax ${parameter name}. params: - name: machineArch value: X86 #(Optional) Configure either env or envs to set up the build environment. Use envs if you need to specify conditions to determine the host specification and type. env: resource: type: docker arch: X86 class: 8U16G pool: Mydocker envs: - condition: machineArch == 'ARM' resource: type: docker arch: ARM - condition: machineArch == 'X86' resource: type: docker arch: X86 #Build actions steps: PRE_BUILD: - checkout: name: checkout inputs: scm: codehub url: git@codehub.devcloud.cn-north-7.ulanqab.huawei.com:huang-test00001/maven.git branch: master commit: commitId lfs: true submodule: true depth: 100 tag: tag path: test - manifest_checkout: name: "manifest" inputs: manifest_url: https://codehub.devcloud.xxxxxxx.ulanqab.huawei.com/IPD-xxxxxx/manifest.git manifest_branch: master manifest_file: default.xml path: dir/dir02 lfs: true repo_url: https://codehub.devcloud.xxxxxxx.ulanqab.huawei.com/IPD-xxxxxx/git-repo.git repo_branch: master username: someone password: PASSWD - sh: inputs: command: echo ${machineArch} BUILD: # Build actions - maven: name: Build with Maven image: cloudbuild@maven3.5.3-jdk8-open inputs: settings: public_repos: - https://mirrors.huawei.com/maven cache: true unit_test: coverage: true ignore_errors: false report_path: "**/TEST*.xml" enable: true coverage_report_path: "**/site/jacoco" command: mvn package -Dmaven.test.failure.ignore=true -U -e -X -B check: project_dir: ./ settings: ~/.m2/settings.xml param: '' - upload_artifact: inputs: path: "**/target/*.?ar" version: 2.1 name: packageName
Parameter |
Type |
Description |
Mandatory |
---|---|---|---|
version |
String |
YAML file version specified with a fixed value. Currently, the only supported version is 2.0. |
Yes |
params |
Map |
Global parameter configuration. These parameters must be specified in pairs, with a name and a corresponding value. If no value is assigned to a parameter, it will default to an empty string. When referencing a parameter, use the syntax ${parameter name}. In the preceding sample code, the defined parameter is referenced as an input parameter by following the format ${machineArch}. When used as a condition, the declared parameter name machineArch is applied.
|
No |
env |
Map |
This build environment configuration serves the same purpose as envs. You can configure either of them. However, env does not support condition statements. For details, see the example in Configuring the Build Environment.
|
No |
envs |
Map |
This build environment configuration serves the same purpose as env. You can configure either of them. Unlike env, envs supports condition statements, allowing for more flexible usage of the same YAML file in different scenarios.
|
No |
steps |
Map |
A collection of build actions. This parameter configures the build process by specifying:
|
Yes |
steps: PRE_BUILD |
Map |
This parameter defines build preparations, typically code downloads before the actual build process begins. Currently, only checkout, manifest_checkout, and sh are supported. Generally, you only need to configure one of them.
|
Yes |
steps: BUILD |
Map |
This parameter defines and runs service-specific build tasks. Only a particular set of build actions are supported and can be flexibly combined to meet service requirements. For details about the build actions, see Selecting Build Actions.
|
Multi-task Build
--- version: 2.0 #Parameters are specified in pairs, with a name and a corresponding value. If no value is assigned to a parameter, it will default to an empty string. When referencing a parameter, use the syntax ${parameter name}. params: - name: machineArch value: X86 - name: jobCondition value: 1 - name: jobsCondition value: 1 # (Optional) Configure either env or envs to set up the build environment. Use envs if you need to specify conditions to determine the host specification and type. env: resource: type: docker arch: X86 class: 8U16G pool: Mydocker envs: - condition: machineArch == 'ARM' resource: type: docker arch: ARM - condition: machineArch == 'X86' resource: type: docker arch: X86 # Configure either buildflow or buildflows. Use buildflows if you need to specify conditions to control job executions. buildflow: strategy: Lazy jobs: - job: Job3 depends_on: - Job1 - Job2 build_ref: .cloudbuild/build3.yml - job: Job1 build_ref: .cloudbuild/build1.yml - job: Job2 build_ref: .cloudbuild/build2.yml buildflows: - condition: jobsCondition == 1 jobs: - job: Job1 build_ref: .cloudbuild/build1.yml params: - name: job1Params value: 1 - condition: jobCondition == 1 job: Job2 build_ref: .cloudbuild/build2.yml params: - name: job2Params value: 2 - job: Job3 depends_on: - Job1 - Job2 build_ref: .cloudbuild/build3.yml - condition: jobsCondition == 2 jobs: - job: Job3 build_ref: .cloudbuild/build3.yml
Parameter |
Type |
Description |
Mandatory |
---|---|---|---|
version |
String |
YAML file version specified with a fixed value. Currently, the only supported version is 2.0. |
Yes |
params |
Map |
Global parameter configuration. These parameters must be specified in pairs, with a name and a corresponding value. If no value is assigned to a parameter, it will default to an empty string. When referencing a parameter, use the syntax ${parameter name}. In the preceding sample code, the defined parameter is referenced as an input parameter by following the format ${machineArch}. When used as a condition, the declared parameter name machineArch is applied.
|
No |
env |
Map |
This build environment configuration serves the same purpose as envs. You can configure either of them. However, env does not support condition statements.
|
No |
envs |
Map |
This build environment configuration serves the same purpose as env. You can configure either of them. Unlike env, envs supports condition statements, allowing for more flexible usage of the same YAML file in different scenarios.
|
No |
buildflow |
Map |
A build job (referring to the build task on the GUI) is the smallest unit that a build project can be broken down into for simple service scenarios. However, for more complex requirements, you may need to use a multi-repo approach to distribute build jobs that depend on each other across multiple machines. In certain scenarios, you may need to set up multiple build tasks in a modular and fine-grained way, and run them in a specific order. Each task depends on the successful completion of its dependency task. To handle such complex builds, CodeArts Build offers a task model called BuildFlow, which organizes multiple build jobs in a directed acyclic graph (DAG) and runs them in parallel with the maximum capacity based on job dependencies. By doing so, CodeArts Build helps improve build efficiency.
|
|
buildflows |
Map |
Configure buildflows if you need to specify conditions. Adapt to different service scenarios for a better use of YAML files.
|
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