steps.checkout definition

Utilize checkout para configurar a forma como o pipeline dá saída do 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 referenciam esta definição: passos

Propriedades

checkout cadeia. Necessário como primeira propriedade.
Configura a finalização da compra para o repositório especificado. Especifique self, none, nome do repositório ou recurso de repositório. Para obter mais informações, veja Dar saída de vários repositórios no pipeline.

Nota

Se não existir nenhum checkout passo, a predefinição self é para e none para jobs.job.step.checkoutjobs.deployment.steps.checkout.

checkout cadeia. Necessário como primeira propriedade.
Se pretende ou não dar saída do repositório que contém esta definição de pipeline. Especifique self ou none.

clean cadeia.
Se for verdadeiro, execute git clean -ffdx seguido de git reset --hard HEAD antes de obter. true | falso.

fetchDepth cadeia.
Profundidade do grafo do Git a obter.

fetchTags cadeia.
Defina como "true" para sincronizar etiquetas ao obter o repositório ou "falso" para não sincronizar etiquetas. Veja comentários sobre o comportamento predefinido.

lfs cadeia.
Defina como "true" para transferir ficheiros Git-LFS. A predefinição não é transferi-las.

persistCredentials cadeia.
Defina como "true" para deixar o token OAuth na configuração do Git após a obtenção inicial. A predefinição não é deixá-la.

submodules cadeia.
Defina como "verdadeiro" para um único nível de submódulos ou "recursivo" para obter submódulos de submódulos. A predefinição é não obter submódulos.

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

condition cadeia.
Avalie esta expressão de condição para determinar se deve executar esta tarefa.

continueOnErrorbooleano.
Continuar a executar mesmo com falhas?

displayName cadeia.
Nome legível por humanos para a tarefa.

targetdestino.
Ambiente no qual executar esta tarefa.

enabledbooleano.
Executar esta tarefa quando a tarefa for executada?

env dicionário de cadeia.
Variáveis a mapear para o ambiente do processo.

name cadeia.
ID do passo. Valores aceitáveis: [-_A-Za-z0-9]*.

timeoutInMinutes cadeia.
Está na hora de esperar que esta tarefa seja concluída antes de o servidor a matar.

Nota

Os pipelines podem ser configurados com um tempo limite ao nível da tarefa. Se o intervalo de tempo limite do nível da tarefa terminar antes da conclusão do passo, a tarefa em execução (incluindo o passo) será terminada, mesmo que o passo esteja configurado com um intervalo mais longo timeoutInMinutes . Para obter mais informações, veja Tempos limite.

retryCountOnTaskFailure cadeia.
Número de tentativas se a tarefa falhar.

Observações

Obtenção rasa

Importante

Os novos pipelines criados após a atualização de setembro de 2022 do Sprint 209 do Azure DevOps têm a Obtenção rasa ativada por predefinição e configurada com uma profundidade de 1. Anteriormente, a predefinição não era a obtenção superficial. Para verificar o pipeline, veja a definição Obtenção rasa na IU das definições do pipeline.

Para desativar a obtenção superficial, pode executar uma das duas opções seguintes.

Para configurar a profundidade de obtenção de um pipeline, pode definir a fetchDepth propriedade no checkout passo ou configurar a definição Obtenção rasa na IU das definições do pipeline.

Nota

Se definir fetchDepth explicitamente no seu checkout passo, essa definição tem prioridade sobre a definição configurada na IU das definições do pipeline. A definição fetchDepth: 0 obtém todo o histórico e substitui a definição Obtenção rasa .

Limpar propriedade

Se a clean propriedade não estiver definida, o valor predefinido é configurado pela definição limpa nas definições de IU para pipelines YAML, que está definido como verdadeiro por predefinição. Além da opção de limpeza disponível com checkouto , também pode configurar a limpeza numa área de trabalho. Para obter mais informações sobre áreas de trabalho e opções limpas, veja o tópico da área de trabalho em Tarefas.

Etiquetas de sincronização

O passo de finalização da compra utiliza a opção --tags ao obter os conteúdos de um repositório Git. Isto faz com que o servidor obtenha todas as etiquetas, bem como todos os objetos que são apontados por essas etiquetas. Isto aumenta o tempo para executar a tarefa num pipeline, especialmente se tiver um repositório grande com várias etiquetas. Além disso, o passo de finalização da compra sincroniza as etiquetas mesmo quando ativa a opção de obtenção rasa, possivelmente derrotando o seu objetivo. Para reduzir a quantidade de dados obtidos ou extraídos de um repositório Git, a Microsoft adicionou uma nova opção para dar saída para controlar o comportamento das etiquetas de sincronização. Esta opção está disponível em pipelines clássicos e YAML.

A sincronização de etiquetas ao dar saída de um repositório pode ser configurada no YAML ao definir a fetchTags propriedade e na IU ao configurar a definição Etiquetas de sincronização.

Para configurar a definição no YAML, defina a fetchTags propriedade .

steps:
- checkout: self
  fetchTags: true

Para configurar a definição na IU do pipeline, edite o pipeline YAML e selecione Mais ações, Acionadores, YAML, Obter origens e selecione ou desmarque a caixa de verificação Etiquetas de sincronização. Para obter mais informações, veja Sincronizar etiquetas.

Comportamento predefinido

  • Para os pipelines existentes criados antes do lançamento do sprint 209 do Azure DevOps, lançado em setembro de 2022, a predefinição para sincronizar etiquetas permanece igual ao comportamento existente antes da adição das opções De sincronização de etiquetas , que é true.
  • Para novos pipelines criados após a versão 209 do sprint do Azure DevOps, a predefinição para sincronizar etiquetas é false.

Importante

Uma definição de Etiquetas de sincronização verdadeira na IU tem precedência sobre uma fetchTags: false instrução no YAML. Se As etiquetas de Sincronização estiverem definidas como verdadeiras na IU, as etiquetas são sincronizadas mesmo que fetchTags estejam definidas como falsas no YAML.

Exemplos

Para evitar sincronizar origens:

steps:
- checkout: none

Nota

Se estiver a executar o agente na conta do Serviço Local e quiser modificar o repositório atual através de operações do git ou ao carregar submódulos git, atribua as permissões adequadas ao utilizador das Contas do Serviço de Compilação da Coleção de Projetos.

- checkout: self
  submodules: true
  persistCredentials: true

Para dar saída de vários repositórios no pipeline, utilize vários checkout passos:

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

Para obter mais informações, veja Dar saída de vários repositórios no pipeline.

Ver também