Azure DevOps Yaml Pipline gitversion/执行/_/LibGit2Sharp/Core/Handles/Objects.cs中失败的ObjectHandle.op_Implicit(ObjectHandle句柄):第509行

Jan*_*wak 6 gitversion azure-devops azure-pipelines

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 在没有在 yaml 中进行设置的选项的azure devops yaml 管道上运行任务 gitversion/execute 时出现错误 ##[debug]fetchDepth=1 ,因为这已更改为 Microsoft 的默认值。

Jan*_*wak 10

设置获取的选项隐藏在 ADO 中的管道编辑按钮 -> 触发器 -> 下在此输入图像描述

或者使用

variables:
  Agent.Source.Git.ShallowFetchDepth: 0
Run Code Online (Sandbox Code Playgroud)

或者如果存储库也作为专用任务签出

steps:
  - checkout: self
    fetchDepth: 0
    clean: true
Run Code Online (Sandbox Code Playgroud)


Syl*_*gue 6

2022 年 9 月之后创建的管道会发生这种情况。如果您使用的是 YAML 管道,请替换:

- checkout: self
  persistCredentials: true
Run Code Online (Sandbox Code Playgroud)

和:

- checkout: self
  fetchDepth: 0
  persistCredentials: true
Run Code Online (Sandbox Code Playgroud)

-checkout任务在 2022 年 9 月之后创建的管道中执行浅层提取。由于 gitversion 需要完整的提交历史记录来查找标签,因此它会尝试并崩溃。指定fetchDepth: 0禁用浅读取。

参考文献:GitversionMicrosoft .