There is a build pipeline which has the below code.
resources:
repositories:
- repository: repName
type: git
ref: branchname
name: project/repo
jobs:
- job: prerequisite
timeoutInMinutes: 120
displayName: Setup variables
steps:
- checkout: self
- checkout: repName
When pipeline is run, we get the below error.
HEAD is now at 72bc708d Update azure-pipelines.yml for Azure Pipelines
##[warning]Git checkout failed on shallow repository, this might because of git fetch with depth '1' doesn't include the checkout commit 'refs/remotes/origin/85hgf1234754b65aaadc947c195313b626a4bb72'. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=829603)
##[error]Git checkout failed with exit code: 1
If repositories section is not present and checkout is not specified, which means multiple repositories not involved - check out will be successful without any error.
Any idea on this? Why does checkout fail when multiple repositories involved?
Have tested without repository section and it succeeds everytime.
Make sure that the shallow fetch option of your build is not enabled. It is unfortunately enabled by default when a new pipeline is created. To change that: Go to your pipeline -> Edit -> The 3 dots menu top right -> Triggers -> YAML tab -> Get Sources section -> Uncheck the Shallow Fetch option at the bottom of the page -> Save