Trying to use the treeless fetch to get all the commit history for blame attribution in Sonarqube.But end up getting the error above.
The environment is Azure devops with a hosted agent. Git version shows - git-lfs/3.4.0 (GitHub; windows amd64; go 1.20.6; git d06d6e9e)
Tried using the instructions here https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-checkout?view=azure-pipelines
specifically
fetchFilter string. Use fetchFilter to filter Git history for partial cloning. The fetchFilter setting supports treeless and blobless fetches. For a treeless fetch, specify fetchFilter: tree:0 and to specify a blobless fetch, specify fetchFilter: blob:none. The default is no filtering.
Relevant azure-pipeline.yaml section
steps:
- checkout: self
clean: true
fetchFilter: tree:0
The build throws the error - fatal: could not fetch SHA from promisor remote
I can reproduce the same issue when adding the fetchFilter
in the checkout step.
This could be related to the git credential when setting the fetchFilter
argument. When you set the fetchFilter
, the git command will not able to get the credential.
The issue is from the checkout feature itself. I suggest that you can report the issue to Developer Community. Azure DevOps Developers will investigate this feature further.
For a workaround, you can add an additional checkout step(set persistCredentials:true
) before the existing checkout step to pre-config the git credential.
For example:
steps:
- checkout: self
persistCredentials: true
path: storecred
- checkout: self
clean: true
fetchFilter: tree:0
persistCredentials: true
Result: