Azure DevOps FetchDepth Explained and Its Impact on Pipelines

Author

Reads 668

From above crop anonymous male programmer in black hoodie working on software code on contemporary netbook and typing on keyboard in workspace
Credit: pexels.com, From above crop anonymous male programmer in black hoodie working on software code on contemporary netbook and typing on keyboard in workspace

Azure DevOps FetchDepth is a crucial concept that can significantly impact the performance of your pipelines. FetchDepth determines how many changesets are retrieved from the server during a get operation.

The default FetchDepth is 0, which means all changesets are retrieved. However, this can lead to slow performance and increased network traffic.

Increasing FetchDepth can improve performance, but it also increases the amount of data retrieved. For example, setting FetchDepth to 1 retrieves only the current changeset, while setting it to 2 retrieves the current and previous changeset.

What is FetchDepth

FetchDepth is a setting in Azure DevOps pipelines that determines how many commits are fetched from the repository. Since September 12th, new pipelines have a fetch depth of 1 by default.

This means previous commits are not fetched and cannot be scanned, which can cause issues like Gitleaks reporting ERR [git] fatal: bad object.

To avoid this problem, you need to be aware of the fetch depth setting and its impact on your pipeline.

Definition

Woman in focus working on software development remotely on laptop indoors.
Credit: pexels.com, Woman in focus working on software development remotely on laptop indoors.

FetchDepth is a concept that refers to the maximum depth of a fetch operation in a database query. It's a measure of how many levels deep a query can go before it reaches a leaf node.

FetchDepth is often used to optimize database performance by limiting the number of joins in a query. This can help prevent performance issues caused by too many nested queries.

The FetchDepth parameter is typically set by the database administrator to control the maximum depth of fetch operations. This can be done to prevent denial-of-service attacks or to improve query performance.

FetchDepth is related to the concept of recursion, which is a common technique used in database queries to traverse hierarchical data. By limiting the FetchDepth, you can prevent recursive queries from running indefinitely.

On a similar theme: Azure Boards Queries

Purpose

FetchDepth is a tool designed to help developers measure the performance of their websites. It provides a detailed report on the time it takes for a user's browser to load the content of a page, highlighting potential bottlenecks and areas for improvement.

Two keyboard keys on a red background, depicting 'ctrl' and 'N'.
Credit: pexels.com, Two keyboard keys on a red background, depicting 'ctrl' and 'N'.

By analyzing the FetchDepth report, developers can identify which resources are taking the longest to load and prioritize their optimization efforts accordingly. This approach helps to streamline the development process and improve overall user experience.

FetchDepth's focus on measuring the performance of individual resources allows developers to pinpoint specific issues and make targeted improvements. For instance, if a developer notices that a particular image is taking a long time to load, they can optimize the image or find an alternative solution.

By optimizing the loading time of individual resources, developers can significantly reduce the overall page load time, making the website more responsive and user-friendly.

Take a look at this: Azure Devops Remove User

FetchDepth Impact

Since September 12th (Sprint 209) release of Azure DevOps, new pipelines have a fetch depth of 1, which means previous commits are not fetched and cannot be scanned.

This results in Gitleaks reporting: ERR [git] fatal: bad object.

To solve this issue, there are two options:

Azure DevOps Pipelines

Female Software Engineer Coding on Computer
Credit: pexels.com, Female Software Engineer Coding on Computer

Azure DevOps Pipelines have a new default setting that might catch you off guard. Newly created pipelines now have shallow fetch enabled by default, with a depth of 1.

This change was made quickly, with the documentation team updating the steps.checkout definition and Build Azure Repos Git or TFS Git repositories within two days of reporting the issue.

Azure DevOps Pipelines with shallow fetch enabled by default may break newly created pipelines. Things that used to work won't, due to the new default setting.

The team responsible for the documentation was fast in updating the relevant documentation. If you come across any outdated documentation, try reporting it to get it updated.

Curious to learn more? Check out: Azure Devops Reporting

Shallow Fetch

Shallow Fetch is a feature in Azure DevOps that fetches only the latest commit and not all the history. This can be useful for pipelines that don't need the entire commit history.

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.

Diverse team collaborating on a software project in a contemporary office setting.
Credit: pexels.com, Diverse team collaborating on a software project in a contemporary office setting.

To check your pipeline's Shallow fetch setting, view the Shallow fetch setting in the pipeline settings UI. You can also explicitly set fetchDepth: 0 in your checkout step to disable shallow fetch.

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.

You can configure the fetch depth for a pipeline by setting the fetchDepth property in the checkout step, or by configuring 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.

Lee Mohr

Writer

Lee Mohr is a skilled writer with a passion for technology and innovation. With a keen eye for detail and a knack for explaining complex concepts, Lee has established himself as a trusted voice in the industry. Their writing often focuses on Azure Virtual Machine Management, helping readers navigate the intricacies of cloud computing and virtualization.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.