如何将 git 短散列附加到 TeamCity 的 Octopus 版本中

How to append git short hash into Octopus release from TeamCity

在 TeamCity 中使用 OctopusDeploy: Create Release 运行器,我可以相当轻松地创建带有 build.number 的版本。

我想添加 git 提交短哈希的后缀。

这是我解决它的方法 - 从各种互联网资源中抓取

在我的 CI Build 中,我添加了

  1. 一个名为 system.GitHashShort
  2. 的参数
  3. 创建了执行此操作的 Powershell 运行程序

    $hash = "%build.vcs.number%" $shortHash = $hash.substring(0,7) Write-Host "##teamcity[setParameter name='system.GitHashShort' value='$shortHash']"

在我的 Deploy 构建配置中,它是对 CI Build

的快照依赖
  1. 对于 OctopusDeploy: Create Release 跑步者,将 发布号 设置为

    %build.number%-%dep.MyAwesomeApp.system.GitHashShort%

这会给出类似 8.3.422.34-deadbee

格式的构建