A pipeline job is a collection of steps that run sequentially in a shared workspace. Alternatively, a job can be a single call to a component, which supports advanced operations such as retries and skips.
Examples
-
Configure a
jobwith multiplesteps:stages: build_stage: name: Build Stage jobs: build_job: name: Build Job runsOn: public/cn-beijing steps: # Configure the steps for the job build_step: step: JavaBuild name: Java Build with: ...... upload_step: step: ArtifactUpload name: Artifact Upload with: ...... -
Configure a
jobwith acomponent:stages: build_stage: name: Build Stage jobs: deploy_job: name: VM Deploy Job component: VMDeploy # Configure the job by using a component with: artifact: $[stages.build_stage.build_job.upload_step.artifacts.default] ......
Syntax
stages.<stage_id>.jobs
The collection of jobs for a stage. A job can be a combination of multiple steps or a call to a component.
stages.<stage_id>.jobs.<job_id>
Required. A unique identifier for the job. The job_id must start with a letter and can only contain letters, numbers, and underscores (_). The maximum length is 30 characters.
stages.<stage_id>.jobs.<job_id>.name
Optional. The display name of the job. If omitted, the job_id is used. The maximum length is 30 characters.
stages.<stage_id>.jobs.<job_id>.runsOn
Optional. The execution environment for the job. By default, jobs run on the Alibaba Cloud DevOps public build cluster in Beijing. You can use public build clusters from Alibaba Cloud DevOps or your own self-hosted build clusters. Supported environments: Default Environment, Specified Container Environment, and Default VM Environment.
Default Environment: Starts a container on the build Kubernetes (K8s) cluster or host to perform builds. Syntax:
jobs:
my_job:
name: My Job
runsOn: private/<your_self-hosted_build_cluster_id> // Specifies a self-hosted build cluster and the Default Environment. If omitted, the public build cluster in Beijing is used by default.
Note: The Default Environment is deprecated and will be unavailable for organizations created after April 1, 2025. We recommend using the Specified Container Environment instead.
Specified Container Environment: Runs builds in an isolated container on the build machine. Syntax:
jobs:
my_job:
name: My Job
runsOn:
group: [public/cn-beijing|public/cn-hongkong] // The Specified Container Environment currently supports only public build clusters from Alibaba Cloud DevOps.
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest // A public image address. For official system images from Alibaba Cloud DevOps, see https://atomgit.com/flow-steps/system_images/blob/main/README.md.
|
Build cluster |
YAML identifier |
Description |
|
Alibaba Cloud DevOps Beijing public build cluster |
group: public/cn-beijing |
A public K8s cluster provided by Alibaba Cloud DevOps in the China (Beijing) region. This is the default if |
|
Alibaba Cloud DevOps Hangzhou public build cluster |
group: public/cn-hangzhou |
A public K8s cluster provided by Alibaba Cloud DevOps in the China (Hangzhou) region. |
|
Alibaba Cloud DevOps Hong Kong (China) public build cluster |
group: public/cn-hongkong |
A public K8s cluster provided by Alibaba Cloud DevOps in the Hong Kong (China) region. |
|
Self-hosted build cluster |
group: private/<your_self-hosted_build_cluster_id> |
A private cluster that your organization registers as a self-hosted build cluster. |
Default VM Environment: Runs steps directly on the host machine or virtual machine of the build cluster. Syntax:
jobs:
my_job:
name: My Job
runsOn:
group: private/<your_self-hosted_build_cluster_id> // Only supports self-hosted build clusters.
labels: windows, amd64 // Specifies the OS and architecture for scheduling. If omitted, the job is scheduled to a random machine in the cluster.
vm: true // Specifies the VM build environment. If omitted, the Default Environment is used.
Self-hosted build clusters support Linux, Windows, and macOS machines. The supported architectures and environments for each operating system are as follows:
|
Operating system |
Architecture |
Labels |
Description |
|
Linux |
amd64 |
linux,amd64 |
Supports both the Default Environment and Default VM Environment. |
|
Linux |
arm64 |
linux,arm64 |
Supports only the Default VM Environment. You must specify |
|
Windows |
amd64 |
windows,amd64 |
Supports only the Default VM Environment. You must specify |
|
Windows |
arm64 |
windows,arm64 |
Supports only the Default VM Environment. You must specify |
|
macOS |
amd64 |
darwin,amd64 |
Supports only the Default VM Environment. You must specify |
|
macOS |
arm64 |
darwin,arm64 |
Supports only the Default VM Environment. You must specify |
stages.<stage_id>.jobs.<job_id>.runsOn.instanceType
Optional. The instance type for the job's execution environment. Alibaba Cloud DevOps automatically allocates a DEFAULT instance type based on the steps in the job. For more information about the default type, see build clusters. You can specify a different instance type. Available options: SMALL_1C2G, MEDIUM_2C4G, LARGE_4C8G, XLARGE_8C16G, and XXLARGE_16C32G.
Example:
jobs:
my_job:
name: My Job
runsOn:
group: public/cn-beijing
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest
instanceType: LARGE_4C8G # Specify the instance type
stages.<stage_id>.jobs.<job_id>.timeoutMinutes
Optional. The maximum number of minutes a job can run before it is automatically canceled. The default is 240 minutes. You can set any integer from 1 to 1440.
Example:
jobs:
my_job:
name: My Job
runsOn:
group: public/cn-beijing
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest
timeoutMinutes: 60 # The job will time out 60 minutes after it starts.
stages.<stage_id>.jobs.<job_id>.debugPolicy and stages.<stage_id>.jobs.<job_id>.debugRetentionMinutes
Optional. Retains the job's execution environment after the job completes, allowing you to connect to it for debugging.
This feature is only available for the Specified Container Environment.
These two parameters must be used together or not at all.
The available options for debugPolicy are:
-
onFailure: Retains the environment only if the job fails. The environment is not retained if the job succeeds or is blocked by a quality gate. -
always: Retains the environment regardless of the job's final status.
debugRetentionMinutes is an integer from 1 to 240 that specifies the retention duration in minutes.
Example:
jobs:
my_job:
name: My Job
runsOn:
group: public/cn-beijing
container: build-steps-public-registry.cn-beijing.cr.aliyuncs.com/build-steps/alinux3:latest
debugPolicy: always
debugRetentionMinutes: 5
stages.<stage_id>.jobs.<job_id>.needs
Optional. The prerequisite jobs that must complete successfully before this job runs. By default, all jobs within a stage run in parallel. Use needs to create dependencies between jobs. Note the following:
-
The
needskeyword supports dependencies between jobs in different stages. -
Ensure that dependencies create a clear execution order. Avoid circular dependencies, such as A depending on B, B on C, and C on A.
Specify the <job_id> of the prerequisite job. Example:
jobs:
test_job:
name: Test Job
build_job:
name: Build Job
needs: test_job
stages.<stage_id>.jobs.<job_id>.driven
Optional. The trigger mode for the job. By default, jobs trigger automatically (auto). Supported modes:
-
auto: The job runs automatically. -
manual: The job must be triggered manually.
Example:
jobs:
my_job:
name: My Job
runsOn: public/cn-beijing
driven: manual # Manually trigger the job execution
stages.<stage_id>.jobs.<job_id>.continueOnFail
Optional. If set to true, the pipeline continues to run subsequent jobs even if the current job fails. The default is false, which stops the pipeline run on failure.
jobs:
my_job:
name: My Job
continueOnFail: true # Continue running subsequent jobs on failure
stages.<stage_id>.jobs.<job_id>.condition
Optional. A conditional expression that determines whether the job runs. By default, a job runs only if all its needs dependencies have completed successfully. The job runs when condition evaluates to true.
jobs:
my_job:
name: My Job
runsOn: public/cn-beijing
condition: |
"${CI_COMMIT_REF_NAME}" == "master" # Run this job only when the branch is master.The condition supports relational and logical operators:
|
Operator |
Description |
Example |
|
== |
Equal to |
condition: "${CI_COMMIT_REF_NAME}" == "master" |
|
!= |
Not equal to |
condition: "${CI_COMMIT_REF_NAME}" != "master" |
|
&& |
And |
condition: "${CI_COMMIT_REF_NAME}" == "master" && succeed() |
|
|| |
Or |
condition: "${CI_COMMIT_REF_NAME}" == "master" || "${CI_COMMIT_REF_NAME}" == "develop" |
Built-in functions available in expressions:
|
Function |
Description |
Example |
|
startsWith(searchString, searchValue) |
Returns |
condition: startsWith('Hello world','He') |
|
endsWith(searchString, searchValue) |
Returns |
condition: endsWith('Hello world','ld') |
|
contains(search, item) |
Returns |
condition: contains('["aa", "bb", "cc"]', 'aa') |
|
weekDay() |
Returns the current day of the week (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday). |
condition: weekDay()=="Thursday" |
|
timeIn(startTime, endTime) |
Returns |
condition: timeIn("20:00:00", "22:00:00") |
Note: You can use existing variables as function parameters. For example, if you set a pipeline variable TEST_VAR=["aa", "bb", "cc"], you can reference this variable in a function by using ${}.
jobs:
job_1:
name: 1
condition: contains('${TEST_VAR}', 'aa')
Use job status functions to check the execution status of prerequisite jobs. The function parameter is the <job_id> of the prerequisite job.
|
Function |
Description |
Example |
|
always() |
Always returns |
condition: always() |
|
succeed() |
Returns |
condition: succeed('job_id_1','job_id_2') |
|
failed() |
Returns |
condition: failed('job_id_1','job_id_2') |
Note: If you do not provide parameters to a job status function, it checks all prerequisite jobs. For example, succeed() returns true only if all prerequisite jobs have succeeded. The parameters for job status functions must be the <job_id> of a prerequisite job. Providing the <job_id> of a job that is not a dependency causes an error. Example:
jobs:
job_1:
name: Job 1
job_2:
name: Job 2
job_3:
name: Job 3
needs:
- job_1
- job_2
condition: succeed(job_1) || succeed(job_2) # Run job_3 if job_1 succeeds or job_2 succeeds.
stages.<stage_id>.jobs.<job_id>.sourceOption
Optional. Controls which pipeline sources are downloaded for the job. By default, all configured sources are downloaded. When multiple sources exist, use this option to skip downloading or to download only specific sources by <source_id>.
|
Scenario |
Description |
Example |
|
Download all pipeline sources |
Do not specify |
(not specified) |
|
Do not download any pipeline sources |
Specify |
sourceOption: [] |
|
Download specific pipeline sources |
Specify the |
sourceOption: [repo_1,repo_2] |
stages.<stage_id>.jobs.<job_id>.steps
A job defined as a sequence of steps. All steps in a job share the same workspace and run sequentially.
For more information, see pipeline steps.
stages.<stage_id>.jobs.<job_id>.component
A job defined as a call to a single component. Component-based jobs support advanced features like retries and skips.
For more information, see pipeline components.
stages.<stage_id>.jobs.<job_id>.with
When a job calls a component, use with to pass the execution parameters for the component. For example:
jobs:
deploy_job:
name: VM Deploy Job
runsOn: public/cn-beijing
component: VMDeploy # Specify the component
with: # Provide parameters for the component
artifact: $[stages.build_stage.build_job.upload_step.artifacts.default]
machineGroup: <YOUR-MACHINE-GROUP-ID>
......For more information, see pipeline components.
stages.<stage_id>.jobs.<job_id>.plugins
-
Optional. Configure
pluginsto send job status notifications through DingTalk, email, Enterprise WeChat (WeCom), Feishu, or webhooks. -
For more information, see pipeline plugins.