Shallow fetch for repository

Viewed 7550

I have an Azure Pipeline (yaml) which uses templates and I'm trying to figure out how to setup the fetch depth of the actual repository being cloned.

resources:
  repositories:
    - repository: templates
      type: git
      name: 'DevOps/CICD'
      ref: refs/heads/develop
    - repository: self # sic!
      fetchDepth: 1
      clean: true`

Fetch depth is supported (vscode extension) but I can't seem to find any extensive documentation on it..

3 Answers

Placing this under steps works for me:

steps:
  - checkout: self
    fetchDepth: 1
    clean: true
  - task: NuGetCommand@2
  ...

Results in:

2019-01-17T09:21:45.1133753Z ##[command]git -c http.extraheader="AUTHORIZATION: bearer ***" fetch --tags --prune --progress --no-recurse-submodules --depth=1 origin

Another option is to add the following setting into the Variables section of your YAML pipeline:

variables:
  Agent.Source.Git.ShallowFetchDepth: 1

Azure Pipelines will automatically recognize this setting and use it as a --depth=1 argument when it does git fetch.

Related