steps.checkout 定义
使用 checkout
配置管道签出源代码的方式。
steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
clean: true | false # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
fetchDepth: string # Depth of Git graph to fetch.
fetchFilter: string # Filter Git history.
fetchTags: string # Set to 'true' to sync tags when fetching the repo, or 'false' to not sync tags. See remarks for the default behavior.
lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
sparseCheckoutDirectories: string # Directories for sparse checkout in cone mode and prioritized over sparseCheckoutPatterns if both properties are provided.
sparseCheckoutPatterns: string # Patterns for sparse checkout in non-cone mode that are ignored if sparseCheckoutDirectories is provided.
workspaceRepo: true | false # When true, use the repository root directory as the default working directory for the pipeline. The default is false.
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?
displayName: string # Human-readable name for the task.
target: string | target # Environment in which to run this task.
enabled: boolean # Run this task when the job runs?
env: # Variables to map into the process's environment.
string: string # Name/value pairs
name: string # ID of the step.
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
retryCountOnTaskFailure: string # Number of retries if the task fails.
steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
clean: true | false # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
fetchDepth: string # Depth of Git graph to fetch.
fetchTags: string # Set to 'true' to sync tags when fetching the repo, or 'false' to not sync tags. See remarks for the default behavior.
lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?
displayName: string # Human-readable name for the task.
target: string | target # Environment in which to run this task.
enabled: boolean # Run this task when the job runs?
env: # Variables to map into the process's environment.
string: string # Name/value pairs
name: string # ID of the step.
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
retryCountOnTaskFailure: string # Number of retries if the task fails.
steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
clean: true | false # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
fetchDepth: string # Depth of Git graph to fetch.
lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?
displayName: string # Human-readable name for the task.
target: string | target # Environment in which to run this task.
enabled: boolean # Run this task when the job runs?
env: # Variables to map into the process's environment.
string: string # Name/value pairs
name: string # ID of the step.
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
retryCountOnTaskFailure: string # Number of retries if the task fails.
steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
clean: true | false # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
fetchDepth: string # Depth of Git graph to fetch.
lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?
displayName: string # Human-readable name for the task.
target: string | target # Environment in which to run this task.
enabled: boolean # Run this task when the job runs?
env: # Variables to map into the process's environment.
string: string # Name/value pairs
name: string # ID of the step.
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
steps:
- checkout: string # Required as first property. Whether or not to check out the repository containing this pipeline definition.
clean: true | false # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
fetchDepth: string # Depth of Git graph to fetch.
lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?
displayName: string # Human-readable name for the task.
enabled: boolean # Run this task when the job runs?
env: # Variables to map into the process's environment.
string: string # Name/value pairs
name: string # ID of the step.
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
steps:
- checkout: string # Required as first property. Whether or not to check out the repository containing this pipeline definition.
clean: true | false # If true, run git clean -ffdx followed by git reset --hard HEAD before fetching.
fetchDepth: string # Depth of Git graph to fetch.
lfs: string # Set to 'true' to download Git-LFS files. Default is not to download them.
persistCredentials: string # Set to 'true' to leave the OAuth token in the Git config after the initial fetch. The default is not to leave it.
submodules: string # Set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules. Default is not to fetch submodules.
condition: string # Evaluate this condition expression to determine whether to run this task.
continueOnError: boolean # Continue running even on failure?
displayName: string # Human-readable name for the task.
enabled: boolean # Run this task when the job runs?
env: # Variables to map into the process's environment.
string: string # Name/value pairs
name: string # ID of the step.
timeoutInMinutes: string # Time to wait for this task to complete before the server kills it.
引用此定义的定义:步骤
性能
checkout
字符串。 必需为第一个属性。
配置指定存储库的签出。 指定 self
、none
、存储库名称或 存储库资源。 有关详细信息,请参阅 在管道中签出多个存储库。
注意
如果没有 checkout
步骤,则默认为 jobs.job.step.checkout
self
,jobs.deployment.steps.checkout
none
。
checkout
字符串。 必需为第一个属性。
是否签出包含此管道定义的存储库。 指定 self
或 none
。
clean
字符串。
如果为 true,请在提取之前运行 git clean -ffdx 后跟 git reset --hard HEAD。 true |假。
fetchDepth
字符串。
要提取的 Git 图形深度。
fetchFilter
字符串。
使用 fetchFilter
筛选 Git 历史记录进行部分克隆。
fetchFilter
设置支持无树提取和无 Blob 提取。 对于无树提取,请指定 fetchFilter: tree:0
并指定无 blob 提取,请指定 fetchFilter: blob:none
。 默认值为无筛选。
fetchTags
字符串。
设置为“true”以在提取存储库时同步标记,或设置为“false”以不同步标记。 请参阅有关默认行为的备注。
lfs
字符串。
设置为“true”以下载 Git-LFS 文件。 默认值不是下载它们。
persistCredentials
字符串。
设置为“true”,以在初始提取后将 OAuth 令牌保留在 Git 配置中。 默认值不保留。
submodules
字符串。
设置为“true”,用于单个子模块级别或“递归”以获取子模块的子模块。 默认值不是提取子模块。
path
字符串。
放置存储库的位置。 根目录为 $(Pipeline.Workspace)。 默认情况下,此文件夹必须属于代理工作目录结构。 若要设置代理工作目录外部的路径,请将名为 AZP_AGENT_ALLOW_WORK_DIRECTORY_REPOSITORIES
的管道变量设置为 true,并在签出路径的开头使用前缀 ../
。 在代理版本 3.230.0 及更高版本上受支持。
sparseCheckoutDirectories
字符串。
指定一个目录,以使用目录匹配在圆锥模式下启用稀疏签出。 使用空格分隔多个目录。
- checkout: repo
sparseCheckoutDirectories: src
如果同时设置了 sparseCheckoutDirectories
和 sparseCheckoutPatterns
,则使用 sparseCheckoutDirectories
并忽略 sparseCheckoutPatterns
的设置。
有关稀疏结帐的详细信息,请参阅 使用稀疏签出将 monorepo 缩小到大小。
sparseCheckoutPatterns
字符串。
指定模式以使用模式匹配在非圆锥模式下启用稀疏签出。 使用空格分隔多个模式。
- checkout: repo
sparseCheckoutPatterns: /* !/img
如果同时设置了 sparseCheckoutDirectories
和 sparseCheckoutPatterns
,则使用 sparseCheckoutDirectories
并忽略 sparseCheckoutPatterns
的设置。
有关稀疏结帐的详细信息,请参阅 使用稀疏签出将 monorepo 缩小到大小。
workspaceRepo
字符串。
如果为 true,请使用存储库根目录作为管道的默认工作目录。 默认值为 false。
condition
字符串。
计算此条件表达式以确定是否运行此任务。
continueOnError
布尔。
即使在失败时继续运行?
displayName
字符串。
任务的人可读名称。
target
目标。
运行此任务的环境。
enabled
布尔。
作业运行时运行此任务?
env
字符串字典。
变量以映射到进程的环境。
name
字符串。
步骤的 ID。 可接受的值:[-_A-Za-z0-9]*。
timeoutInMinutes
字符串。
等待此任务在服务器终止之前完成的时间。
注意
管道可配置为作业级别超时。 如果作业级别超时间隔在步骤完成之前已过,则运行作业(包括步骤)将终止,即使该步骤配置了更长的 timeoutInMinutes
间隔。 有关详细信息,请参阅 超时。
retryCountOnTaskFailure
字符串。
如果任务失败, 重试次数。
言论
浅层提取
注意
在某些组织中,在 2022 年 9 月 2022 年 9 月 Azure DevOps 冲刺 209 更新后创建的新管道 默认启用浅层提取 ,并配置深度为 1。 以前,默认值不是浅提取。
若要查看管道,请在 管道设置 UI中查看 浅层提取 设置。
若要禁用浅层提取,可以执行以下两个选项之一。
- 在 管道设置 UI中禁用 浅层提取 选项。
- 在
checkout
步骤中显式设置fetchDepth: 0
。
若要配置管道的提取深度,可以在 checkout
步骤中设置 fetchDepth
属性,也可以在 管道设置 UI中配置 浅层提取 设置。
注意
如果在 checkout
步骤中显式设置 fetchDepth
,该设置优先于管道设置 UI 中配置的设置。 设置 fetchDepth: 0
提取所有历史记录并替代 浅层提取 设置。
Clean 属性
如果 clean
属性未设置,则其默认值由 YAML 管道的 UI 设置中的 干净 设置进行配置,默认情况下设置为 true。 除了使用 checkout
提供的清理选项之外,还可以在工作区中配置清理。 有关工作区和干净选项的详细信息,请参阅 作业中的 工作区 主题。
同步标记
签出步骤在提取 Git 存储库的内容时使用 --tags
选项。 这会导致服务器提取所有标记以及这些标记指向的所有对象。 这会增加在管道中运行任务的时间,尤其是在具有大量标记的大型存储库时。 此外,即使启用浅提取选项,签出步骤也会同步标记,从而可能破坏其目的。 为了减少从 Git 存储库提取或拉取的数据量,Microsoft添加了一个新选项用于签出以控制同步标记的行为。 此选项在经典管道和 YAML 管道中均可用。
签出存储库时是否同步标记,可以通过设置 fetchTags
属性,并在 UI 中配置 同步标记 设置。
若要在 YAML 中配置设置,请设置 fetchTags
属性。
steps:
- checkout: self
fetchTags: true
若要在管道 UI 中配置设置,请编辑 YAML 管道,然后选择 更多作、触发器、YAML、获取源,然后选中或取消选中 同步标记 复选框。 有关详细信息,请参阅 同步标记。
默认行为
- 对于在 2022 年 9 月发布的 Azure DevOps 冲刺 209之前创建的现有管道,同步标记的默认值与添加 同步标记 选项之前的现有行为相同,即
true
。 - 对于在 Azure DevOps 冲刺版本 209 之后创建的新管道,同步标记的默认值为
false
。
重要
UI 中 true 的 同步标记 设置优先于 YAML 中的 fetchTags: false
语句。 如果在 UI 中 同步标记 设置为 true,则即使 YAML 中的 fetchTags
设置为 false,也会同步标记。
例子
有三个选项可用于 checkout
。 默认情况下,Azure DevOps 会签出包含作业 self
的当前存储库。 设置 none
时,不会签出任何存储库。如果指定另一个存储库,则会签出该存储库。若要签出其他存储库,请首先 将其设置为存储库资源。
# Checkout the current repository
steps:
- checkout: self
# Prevent checking out any source code
steps:
- checkout: none
# Checkout a different repository
steps:
- checkout: my-other-repo
为了避免同步源:
steps:
- checkout: none
注意
如果要在本地服务帐户中运行代理,并且想要使用 git作修改当前存储库,或者加载 git 子模块,请为 Project Collection 生成服务帐户用户提供适当的权限。
- checkout: self
submodules: true
persistCredentials: true
若要在管道中签出多个存储库,请使用多个 checkout
步骤:
- checkout: self
- checkout: git://MyProject/MyRepo
- checkout: MyGitHubRepo # Repo declared in a repository resource
有关详细信息,请参阅 在管道中签出多个存储库。