jobs.job definition

作业 是由 代理 或在 服务器上运行的步骤的集合。

jobs:
- job: string # Required as first property. ID of the job.
  displayName: string # Human-readable name for the job.
  dependsOn: string | [ string ] # Any jobs which must complete before this one.
  condition: string # Evaluate this condition expression to determine whether to run this job.
  continueOnError: string # Continue running even on failure?
  timeoutInMinutes: string # Time to wait for this job to complete before the server kills it.
  cancelTimeoutInMinutes: string # Time to wait for the job to cancel before forcibly terminating it.
  variables: variables | [ variable ] # Job-specific variables.
  strategy: strategy # Execution strategy for this job.
  pool: string | pool # Pool where this job will run.
  container: string | container # Container resource name.
  services: # Container resources to run as a service container.
    string: string # Name/value pairs
  workspace: # Workspace options on the agent.
    clean: outputs | resources | all # Which parts of the workspace should be scorched before fetching.
  uses: # Any resources required by this job that are not already referenced.
    repositories: [ string ] # Repository references.
    pools: [ string ] # Pool references.
  steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
  templateContext: # Job related information passed from a pipeline when extending a template.
jobs:
- job: string # Required as first property. ID of the job.
  displayName: string # Human-readable name for the job.
  dependsOn: string | [ string ] # Any jobs which must complete before this one.
  condition: string # Evaluate this condition expression to determine whether to run this job.
  continueOnError: string # Continue running even on failure?
  timeoutInMinutes: string # Time to wait for this job to complete before the server kills it.
  cancelTimeoutInMinutes: string # Time to wait for the job to cancel before forcibly terminating it.
  variables: variables | [ variable ] # Job-specific variables.
  strategy: strategy # Execution strategy for this job.
  pool: string | pool # Pool where this job will run.
  container: string | container # Container resource name.
  services: # Container resources to run as a service container.
    string: string # Name/value pairs
  workspace: # Workspace options on the agent.
    clean: outputs | resources | all # Which parts of the workspace should be scorched before fetching.
  uses: # Any resources required by this job that are not already referenced.
    repositories: [ string ] # Repository references.
    pools: [ string ] # Pool references.
  steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
jobs:
- job: string # Required as first property. ID of the job.
  displayName: string # Human-readable name for the job.
  dependsOn: string | [ string ] # Any jobs which must complete before this one.
  condition: string # Evaluate this condition expression to determine whether to run this job.
  continueOnError: string # Continue running even on failure?
  timeoutInMinutes: string # Time to wait for this job to complete before the server kills it.
  cancelTimeoutInMinutes: string # Time to wait for the job to cancel before forcibly terminating it.
  variables: variables | [ variable ] # Job-specific variables.
  strategy: strategy # Execution strategy for this job.
  pool: string | pool # Pool where this job will run.
  container: string | container # Container resource name.
  services: # Container resources to run as a service container.
    string: string # Name/value pairs
  workspace: # Workspace options on the agent.
    clean: outputs | resources | all # Which parts of the workspace should be scorched before fetching.
  steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.

引用此定义的定义:作业

性能

job 字符串。 必需为第一个属性。
作业的 ID。 可接受的值:有效名称只能包含字母数字字符和“_”,不能以数字开头。

displayName 字符串。
作业的可读名称。

dependsOn 字符串 |字符串列表。
在此作业之前必须完成的任何作业。

condition 字符串。
计算此条件表达式以确定是否运行此作业。

continueOnError 字符串。
即使在失败时继续运行?

timeoutInMinutes 字符串。
等待此作业在服务器终止之前完成的时间。

cancelTimeoutInMinutes 字符串。
等待作业取消的时间,然后强行终止作业。

variables 变量
特定于作业的变量。

strategy jobs.job.strategy
此作业的执行策略。

pool
运行此作业的池。

container jobs.job.container
容器资源名称。

services 字符串字典。
容器资源以服务容器的形式运行。

workspace 工作区
代理上的工作区选项。 有关工作区(包括干净选项)的详细信息,请参阅 作业中的 工作区 主题。

uses jobs.job.uses
此作业所需的任何资源尚未引用。 有关 uses的详细信息,请参阅 将作业授权范围限制为引用的 Azure DevOps 存储库

steps 步骤
要运行的步骤列表。

templateContext templateContext。
扩展模板时从管道传递的作业相关信息。 有关详细信息,请参阅备注。 有关 templateContext的详细信息,请参阅 扩展 YAML 管道模板现在可以传递阶段、作业和部署的上下文信息,模板 - 使用 templateContext 将属性传递给模板

注解

默认 timeoutInMinutes 设置为 60 分钟。 有关详细信息,请参阅 超时

作业可以有条件地运行 ,并且可能 依赖于早期作业

注释

如果只有一个阶段和一个作业,则可以使用 单作业语法 来描述要运行的步骤。

例子

jobs:
- job: MyJob
  displayName: My First Job
  continueOnError: true
  workspace:
    clean: outputs
  steps:
  - script: echo My first job

另请参阅