다음을 통해 공유


steps.checkout definition

Use checkout to configure how the pipeline checks out source code.

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.

Definitions that reference this definition: steps

Properties

checkout string. Required as first property.
Whether or not to check out the repository containing this pipeline definition. Specify self or none.

clean string.
If true, run git clean -ffdx followed by git reset --hard HEAD before fetching. true | false.

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). By default this folder must be under the agent working directory structure. To set a path outside of the agent working directory, set a pipeline variable named AZP_AGENT_ALLOW_WORK_DIRECTORY_REPOSITORIES to true, and use the prefix ../ at the start of your checkout path. Supported on agent version 3.230.0 and higher.

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 string dictionary.
Variables to map into the process's environment.

name string.
ID of the step. Acceptable values: [-_A-Za-z0-9]*.

timeoutInMinutes string.
Time to wait for this task to complete before the server kills it.

Note

Pipelines may be configured with a job level timeout. If the job level timeout interval elapses before your step completes, the running job (including your step) is terminated, even if the step is configured with a longer timeoutInMinutes interval. For more information, see Timeouts.

Remarks

Shallow fetch

Note

In some organizations, new pipelines created after the September 2022 Azure DevOps sprint 209 update have Shallow fetch enabled by default and configured with a depth of 1. Previously the default was not to shallow fetch.

To check your pipeline, view the Shallow fetch setting in the pipeline settings UI.

To disable shallow fetch, you can perform one of the following two options.

  • Disable the Shallow fetch option in the pipeline settings UI.
  • Explicitly set fetchDepth: 0 in your checkout step.

To configure the fetch depth for a pipeline, you can either set the fetchDepth property in the checkout step, or configure the Shallow fetch setting in the pipeline settings UI.

Note

If you explicitly set fetchDepth in your checkout step, that setting takes priority over the setting configured in the pipeline settings UI. Setting fetchDepth: 0 fetches all history and overrides the Shallow fetch setting.

Clean property

If the clean property is unset, then its default value is configured by the clean setting in the UI settings for YAML pipelines, which is set to true by default. In addition to the cleaning option available using checkout, you can also configure cleaning in a workspace. For more information about workspaces and clean options, see the workspace topic in Jobs.

Examples

There are three options for checkout. By default, Azure DevOps checks out the current repository with self for jobs. When you set none, no repository is checked out. If you specify another repository, that repository is checked out. To check out a different repository, set it up as a repository resource first.

# 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

To avoid syncing sources at all:

steps:
- checkout: none

Note

If you're running the agent in the Local Service account and want to modify the current repository by using git operations or loading git submodules, give the proper permissions to the Project Collection Build Service Accounts user.

- checkout: self
  submodules: true
  persistCredentials: true

See also