Getting error when run task gitversion/execute on azure devops yaml pipeline
An unexpected error occurred: System.NullReferenceException: Object reference not set to an instance of an object. at LibGit2Sharp.Core.Handles.ObjectHandle.op_Implicit(ObjectHandle handle) in /_/LibGit2Sharp/Core/Handles/Objects.cs:line 509 at LibGit2Sharp.Core.Proxy.git_commit_author(ObjectHandle obj) in /_/LibGit2Sharp/Core/Proxy.cs:line 289 at
comming from ##[debug]fetchDepth=1
with not option to setup in yaml, as this was change as default value for Microsoft.
Azure DevOps Yaml Pipline gitversion/execute failing ObjectHandle.op_Implicit(ObjectHandle handle) in /_/LibGit2Sharp/Core/Handles/Objects.cs:line 509
Asked Answered
Option to setup fetch is hidden in ADO under pipeline Edit button -> Triggers ->
Or use
variables:
Agent.Source.Git.ShallowFetchDepth: 0
or if the repository is also checkout as dedicated task
steps:
- checkout: self
fetchDepth: 0
clean: true
Awesome! Had a build with this error, and sure, it was exactly what you said here! But, the ShallowFetchDepth has to be greater than 1 in order to be able to find a version starting point, or turned completely off. –
Outcurve
This happens with pipelines created after Sept. 2022. If you're using a YAML pipeline, replace:
- checkout: self
persistCredentials: true
with:
- checkout: self
fetchDepth: 0
persistCredentials: true
The -checkout
task performs a shallow fetch in pipelines created after Septembre 2022. Since gitversion needs the full commit history to find tags, it tries and crashes. Specifying fetchDepth: 0
disable shallow fetch.
References: Gitversion, Microsoft.
© 2022 - 2024 — McMap. All rights reserved.