git - 如何在 VSTS/TFS 构建中检索 Git 提交 ID 和消息?

标签 git continuous-integration azure-devops hockeyapp

我在使用 VSTS 的 CI 环境中,我想获取提交注释以将他设置到文本文件中。

这是我的构建步骤: enter image description here

想法是将 GIT 提交注释复制到存储在工件文件夹中的文本文件中。然后使用 HockeyApp SDK,我将在发布说明中设置我的提交评论。

我可以通过命令行操作轻松复制文件,但我不知道如何检索评论。

最佳答案

环境变量 $(Build.SOURCEVERSIONMESSAGE) 在构建期间设置。您可以直接在任务输入中使用 $(build.SOURCEVERSIONMESSAGE) 访问它。

如果您想在 powershell 脚本或内联 powershell 脚本中访问它。您可以通过环境变量访问它,即 Get-Item Env:\BUILD_SOURCEVERSIONMESSAGE

以下脚本将在二进制文件夹中创建一个新文件 commit.txt,其中包含提交消息。使用具有内联类型的 Powershell 任务运行脚本。

$message = (Get-Item Env:\BUILD_SOURCEVERSIONMESSAGE)

$path =  (Get-Item Env:\BUILD_BINARIESDIRECTORY).Value + '\commit.txt'

echo $message > $path

enter image description here

关于git - 如何在 VSTS/TFS 构建中检索 Git 提交 ID 和消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38199473/

相关文章:

git - git squash 如何处理已删除的文件?

git - 被遗忘的 rebase interactive - git

docker - Gitlab CI/CD Runner 错误 : "unrecognized import path" GOLANG

jenkins - sed 在 jenkins 上失败,但在本地工作

git - 如何强制将功能分支推送到 Gerrit?

git - 本地和远程分支名称相同仍然得到 "The upstream branch of your current branch does not match the name of your current branch "

git - 特定构建配置的 Team City 未决更改不是默认分支

Azure DevOps 托管构建 Controller - 是否支持 Azure 存储模拟器?

.net-core - SonarQube dotnet 核心 : how to avoid the duplicate guid error without altering the default build task

azure-devops - 在 Azure DevOps 中,是否有一种 GUI 方式可以禁用基于 YAML 的管道中的任务?