【问题标题】:Ho do I prevent GitVersion from including the commit hash in the version number?如何阻止 GitVersion 在版本号中包含提交哈希?
【发布时间】:2019-03-30 07:50:17
【问题描述】:

我刚刚开始在 TFS 2018.3(VSTS、Azure DevOps)中使用 GitVersion,并真正尝试了简单的选项。我直接使用GitVersion TFS marketplace 任务。我用 1.1.0.0 标记了主分支并运行了构建。

构建日志显示:

2018-10-25T15:39:53.1843138Z 信息 [10/25/18 17:39:53:08] 更新 装配信息文件 2018-10-25T15:39:53.1843138Z INFO [10/25/18 17:39:53:18] 找到 42 个文件 2018-10-25T15:39:53.3123172Z [部分]异步命令开始:更新内部版本号 2018-10-25T15:39:53.3123172Z 将内部版本号更新为 1.2.0-alpha.354-20181025.1 用于构建 1107

据此,我希望有一个版本 1.2.0-alpha.354-20181025.1,但 AssemblyInformationalVersion 中的结果版本是:

<Assembly: AssemblyInformationalVersion("1.2.0-alpha.354+Branch.develop.Sha.1b44044f1e3324182b9e1f37958b6a4942731e59")>

<Assembly: AssemblyInformationalVersion("1.2.0-some_branch_name.1+366.Branch.feature/some_branch_name.Sha.1b44044f1e3324182b9e1f37958b6a4942731e59")>

有没有办法阻止显示Branch.develop.Sha.1b...

这是使用该任务的正确方法吗?

【问题讨论】:

  • 我认为你可以在 'GitVersion. yaml' 文件,您将在存储库的根目录中创建该文件。

标签: git azure-devops semantic-versioning gitversion


【解决方案1】:

要自定义 GitVersion 的默认设置,您应该在存储库的根目录中添加一个 GitVersion.yml 文件。例如这些内容:

mode: ContinuousDeployment
assembly-informational-format: '{SemVer}-{CommitDate}'
branches: {}
ignore:
  sha: []

这将产生一个版本字符串1.2.0-alpha.354-2018-10-25

要尝试您的 GitVersion.yml 文件是否正常工作,您可以打开命令行并执行 GitVersion.exe /updateassemblyinfo。这仅在您已在本地安装 GitVersion 时才有效,例如与choco install GitVersion.Portable。另见GitVersion docs。但是,执行 GitVersion.exe /updateassemblyinfo 命令将为您提供完整的变量列表,您可以将其包含在 GitVersion.yml 文件中。

【讨论】:

  • 谢谢一百万。我真的需要版本中的日期......我的特定用户/测试人员对此非常挑剔:)
猜你喜欢
  • 2017-11-22
  • 2015-04-14
  • 1970-01-01
  • 1970-01-01
  • 2011-06-14
  • 2017-06-21
  • 2022-10-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多