Alibaba Cloud DevOps Flow supports pipeline as code, allowing you to define your pipeline configuration with a YAML file. Generally, a pipeline includes elements such as sources, stages, jobs, and steps. This topic describes the structure of a YAML pipeline and the syntax rules for its nodes.
Get started with YAML pipelines
To help you quickly grasp the structure of a YAML pipeline, the following YAML file provides an example on how to build and deploy a Java application to a host group:
name: demo-pipeline # Display name of the pipeline
sources: # Configure pipeline sources
my_repo: # Unique identifier of the pipeline source
type: codeup # Type of pipeline source
name: Name of the code source # Display name of the code source
endpoint: <your-codeup-repository-url> # URL of the code source
branch: master # Default branch of the code source
triggerEvents: push # Listener events of the code source
certificate: # Authentication information
type: serviceConnection # Authentication type
serviceConnection: <your-service-connection-id> # Service connection ID
stages: # Configure pipeline stages
build_stage: # Identifier of the stage
name: Build stage # Display name of the stage
jobs: # Configure pipeline jobs
build_job: # Identifier of the job
name: Build job # Display name of the job
runsOn: public/cn-beijing # Cluster environment where the job runs
steps: # Configure pipeline steps
build_step: # Identifier of the step
step: JavaBuild # Select execution step
name: Java build # Display name of the execution step
with: # Parameters of the step
run: |
mvn -B clean package -Dmaven.test.skip=true -Dautoconfig.skip
upload_step:
step: ArtifactUpload
name: Upload build output
with:
uploadType: flowPublic
artifact: default
filePath:
- target/
- deploy.sh
deploy_stage:
name: Deployment stage
jobs:
deploy_job:
name: Host group deployment job
component: VMDeploy # Select execution component
with: # Parameters of the execution component
artifact: $[stages.build_stage.build_job.upload_step.artifacts.default]
machineGroup: <your-machine-group-id>
artifactDownloadPath: /home/admin/app/package.tgz
executeUser: root
run: |
mkdir -p /home/admin/application/
tar zxvf /home/admin/app/package.tgz -C /home/admin/application/
sh /home/admin/application/deploy.sh restartThe following table describes the key nodes in the YAML file.
Node | Node description |
name | The name of the pipeline. |
sources | The pipeline sources. You can configure information such as type, URL, and default branch for each pipeline source. |
sources.<souce_id> | The ID of the pipeline source. Each ID uniquely identifies a pipeline source. |
sources.<souce_id>.type | The type of pipeline source. The following pipeline source types are supported: codeup, github,and gitlab. |
sources.<souce_id>.name | The display name of the pipeline source. |
stages | The pipeline stages. A pipeline stage consists of one or more jobs. |
stages.<stage_id> | The ID of the pipeline stage. Each ID uniquely identifies a pipeline stage. |
stages.<stage_id>.name | The display name of the pipeline stage. |
stages.<stage_id>.jobs | The pipeline jobs. A pipeline job can either be a combination of multiple steps that share a workspace and collaborate to complete a designated job, or a call to a component that executes a specified job, with component tasks supporting additional operations like retries and skips. |
stages.<stage_id>.jobs.<job_id> | The ID of the pipeline job. Each ID uniquely identifies a pipeline job. |
stages.<stage_id>.jobs.<job_id>.name | The display name of the pipeline job. |
stages.<stage_id>.jobs.<job_id>.runsOn | The cluster environment where the pipeline job runs. You can use the public cluster environment provided by Alibaba Cloud DevOps or use a private build cluster. |
stages.<stage_id>.jobs.<job_id>.steps | The pipeline steps. A pipeline job can consist of one or more steps. |
stages.<stage_id>.jobs.<job_id>.steps.<step_id> | The ID of the pipeline step. Each ID uniquely identifies a pipeline step. |
stages.<stage_id>.jobs.<job_id>.steps.<step_id>.step | The execution step of the pipeline. |
stages.<stage_id>.jobs.<job_id>.steps.<step_id>.name | The display name of the pipeline step. |
stages.<stage_id>.jobs.<job_id>.steps.<step_id>.with | The parameters of the pipeline step. |
stages.<stage_id>.jobs.<job_id>.component | The pipeline component. A pipeline job can invoke a component to perform related operations. |
stages.<stage_id>.jobs.<job_id>.with | The parameters of the pipeline component. |