如何在VSTS / TFS构建中检索Git提交ID和消息? [英] How to retrieve Git commit id and message in VSTS/TFS build?

查看:251
本文介绍了如何在VSTS / TFS构建中检索Git提交ID和消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm in a CI environment using VSTS and I want to get the commit comment to set him into a text file.

以下是我的构建步骤:

Here are my build step :

这个想法是将GIT提交注释复制到存储在工件文件夹中的文本文件中。然后用HockeyApp SDK,我会在注释中设置我的提交注释。

The idea is to copy the GIT commit comment into a text file stored in the artifact folder. Then with the HockeyApp SDK, i'll set my commit comment in the relase note.

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

I can easily copy the file with a command line operation, but I do not know how the retrieve the comment.

推荐答案

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

The environment variable $(Build.SOURCEVERSIONMESSAGE) is set during build. You can access it using $(build.SOURCEVERSIONMESSAGE) directly in your task inputs.

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

If you want to access it in a powershell script or inline powershell script. You can access it via the environment variable i.e. Get-Item Env:\BUILD_SOURCEVERSIONMESSAGE

以下脚本将创建在带有提交信息的二进制文件夹中有一个新的文件commit.txt。

The following script will create a new file commit.txt in the binaries folder with commit message in it. Run the script using the Powershell task with inline Type.

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

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

echo $message > $path

这篇关于如何在VSTS / TFS构建中检索Git提交ID和消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆