Share via


definição steps.checkout

Use checkout para configurar como o pipeline verifica o código-fonte.

steps:
- checkout: string # Required as first property. Configures checkout for the specified repository.
  clean: string # 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: string # 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: string # 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: string # 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: string # 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.

Definições que fazem referência a essa definição: etapas

Propriedades

checkout String. Obrigatório como primeira propriedade.
Configura o check-out para o repositório especificado. Especifique self, none, nome do repositório ou recurso de repositório. Para obter informações, confira Fazer check-out de vários repositórios no pipeline.

Observação

Se nenhuma checkout etapa estiver presente, o padrão self será para jobs.job.step.checkout e none para jobs.deployment.steps.checkout.

checkout String. Obrigatório como primeira propriedade.
Se deve ou não marcar o repositório que contém essa definição de pipeline. Especifique self ou none.

clean String.
Se for true, execute git limpo -ffdx seguido por git reset --hard HEAD antes de buscar. true | False.

fetchDepth String.
Profundidade do grafo do Git a ser buscada.

fetchTags String.
Defina como 'true' para sincronizar marcas ao buscar o repositório ou 'false' para não sincronizar marcas. Confira os comentários sobre o comportamento padrão.

lfs String.
Defina como 'true' para baixar arquivos git-LFS. O padrão não é baixá-los.

persistCredentials String.
Defina como 'true' para deixar o token OAuth na configuração do Git após a busca inicial. O padrão é não deixá-lo.

submodules String.
Defina como 'true' para um único nível de submódulos ou 'recursivo' para obter submódulos de submódulos. O padrão não é buscar submódulos.

path String.
Onde colocar o repositório. O diretório raiz é $(Pipeline.Workspace).

condition String.
Avalie essa expressão de condição para determinar se essa tarefa deve ser executada.

continueOnErrorbooliano.
Continuar em execução mesmo em caso de falha?

displayName String.
Nome legível para a tarefa.

targetdestino.
Ambiente no qual executar essa tarefa.

enabledbooliano.
Executar essa tarefa quando o trabalho for executado?

env dicionário de cadeia de caracteres.
Variáveis a serem mapeadas para o ambiente do processo.

name String.
ID da etapa. Valores aceitáveis: [-_A-Za-z0-9]*.

timeoutInMinutes String.
Tempo de espera para que essa tarefa seja concluída antes que o servidor a mate.

Observação

Os pipelines podem ser configurados com um tempo limite de nível de trabalho. Se o intervalo de tempo limite do nível do trabalho decorrer antes da conclusão da etapa, o trabalho em execução (incluindo a etapa) será encerrado, mesmo que a etapa esteja configurada com um intervalo mais longo timeoutInMinutes . Para obter mais informações, consulte Tempos limite.

retryCountOnTaskFailure String.
Número de novas tentativas se a tarefa falhar.

Comentários

Fetch superficial

Importante

Novos pipelines criados após a atualização do Azure DevOps sprint 209 de setembro de 2022 têm o fetch superficial habilitado por padrão e configurado com uma profundidade de 1. Anteriormente, o padrão não era efetuar fetch superficialmente. Para marcar seu pipeline, exiba a configuração busca superficial na interface do usuário das configurações do pipeline.

Para desabilitar a busca superficial, você pode executar uma das duas opções a seguir.

Para configurar a profundidade de busca para um pipeline, você pode definir a fetchDepth propriedade na checkout etapa ou definir a configuração de busca superficial na interface do usuário das configurações do pipeline.

Observação

Se você definir fetchDepth explicitamente em sua etapa checkout, essa configuração terá prioridade sobre a configuração definida na interface do usuário das configurações do pipeline. A configuração de fetchDepth: 0 efetua fetch de todo o histórico e substitui a configuração Fetch superficial.

Propriedade Clean

Se a clean propriedade não for definida, seu valor padrão será configurado pela configuração limpo nas configurações da interface do usuário para pipelines YAML, que é definido como true por padrão. Além da opção de limpeza disponível usando checkout, você também pode configurar a limpeza em um workspace. Para obter mais informações sobre workspaces e opções de limpo, consulte o tópico do workspace em Trabalhos.

Sincronizar tags

A etapa de check-out usa a opção --tags ao efetuar fetch do conteúdo de um repositório Git. Isso faz com que o servidor efetue fetch de todas as tags, bem como todos os objetos apontados por essas tags. Isso aumenta o tempo para executar a tarefa em um pipeline, especialmente se você tiver um repositório grande com várias tags. Além disso, a etapa de check-out sincroniza tags mesmo quando você habilita a opção de fetch superficial, anulando a utilidade dela. Para reduzir a quantidade de dados buscados ou extraídos de um repositório Git, a Microsoft adicionou uma nova opção de check-out para controlar o comportamento das tags de sincronização. Essa opção está disponível em pipelines clássicos e YAML.

Se as tags devem ou não ser sincronizadas ao fazer check-out de um repositório é algo que pode ser configurado no YAML pela definição da propriedade fetchTags e na interface do usuário pela configuração Sincronizar tags.

Para definir a configuração no YAML, defina a propriedade fetchTags.

steps:
- checkout: self
  fetchTags: true

Para definir a configuração na interface do usuário do pipeline, edite seu pipeline YAML e escolha Mais ações, Gatilhos, YAML, Obter fontes e marcar ou desmarque a caixa de seleção Sincronizar marcas. Para obter mais informações, consulte Sincronizar marcas.

Comportamento padrão

  • Para pipelines existentes criados antes do lançamento do Azure DevOps sprint 209, lançado em setembro de 2022, o padrão para sincronizar marcas permanece o mesmo que o comportamento existente antes da adição das opções Sincronizar tags, que é true.
  • Para novos pipelines criados após a versão 209 do Azure DevOps sprint, o padrão para sincronizar tags é false.

Importante

Uma configuração sincronizar marcas de true na interface do usuário tem precedência sobre uma fetchTags: false instrução no YAML. Se As marcas de sincronização estiverem definidas como true na interface do usuário, as marcas serão sincronizadas mesmo se fetchTags estiver definido como false no YAML.

Exemplos

Para evitar sincronizar fontes:

steps:
- checkout: none

Observação

Se você estiver executando o agente na conta de Serviço Local e quiser modificar o repositório atual usando operações git ou carregando submódulos git, forneça as permissões adequadas para o usuário de Contas de Serviço de Build do Project Collection.

- checkout: self
  submodules: true
  persistCredentials: true

Para fazer check-out de vários repositórios no seu pipeline, use várias etapas checkout:

- checkout: self
- checkout: git://MyProject/MyRepo
- checkout: MyGitHubRepo # Repo declared in a repository resource

Para obter mais informações, confira Fazer check-out de vários repositórios no pipeline.

Confira também