Azure DevOps Pipelines: Skip resolving deltas + tags in Checkout

Viewed 314

In Azure DevOps for any pipeline it takes around a minute to checkout the code. I have configured the fetch depth to 1 to speed it up but this doesn't have any effect on the time. It spends around 10-15 seconds Receiving objects but after it has finished downloading the code it then goes through a process of Resolving deltas and listing tags [new tag] which came when we migrated the history from TFS to git.

Sample lines from log:

Receiving objects: 100% (139543/139543), 391.48 MiB | 19.37 MiB/s, done.
Resolving deltas:   0% (0/91447)
[new tag]       TFS_C10006 -> TFS_C10006

Pipeline snippet:

stages:  
- stage: Build  
  jobs:  
  - job: Build
    steps:
    - checkout: self
      fetchDepth: 1
      clean: true

Do you know any settings which can be turned on at the pipeline to ignore tags and skip the deltas? It takes the same amount of time on every Pipeline execution.

2 Answers

There is a new option in Azure Devops to not sync tags when fetching a Git repository.

To opt-out from syncing the tags through YAML file, add the noTags: true to the checkout step. When the noTags option is not specified, it's the same as if noTags: false is used.

If you want to change the behavior of existing YAML pipelines, it may be more convenient to set this option in the UI instead of updating the YAML file. To navigate to the UI, open the YAML editor for the pipeline, select Triggers, then Process, and then the Checkout step.

If you specify this setting both in the YAML file and in the UI, then the value specified in the UI takes precedence.

Also, make sure you have Shallow Fetch enabled (it's enabled by default in Azure DevOps).

Test and confirm you are getting better results.

Reference: https://learn.microsoft.com/en-us/azure/devops/release-notes/2022/sprint-209-update?tabs=yaml#do-not-sync-tags-when-fetching-a-git-repository

Related