访问 Azure Pipeline YAML 中的扩展(多行)Git 提交消息
Accessing the extended (multi-line) Git commit message in Azure Pipeline YAML
在 AppVeyor 中,我们使用 APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED
environment variable 获取 Git 提交消息的扩展部分,但我在 Azure Pipelines 中看不到等效项。
如果我创建一个包含 printenv | sort
的 bash
步骤来查看我的 YAML 管道中的所有可用环境变量,那么输出表明 BUILD_SOURCEVERSIONMESSAGE
仅包含提交消息,并且不存在 EXTENDED
等价物。我也看不到文档中的任何内容。我们的存储库托管在 GitHub 中,而不是托管在 Azure DevOps 中(如果这有所不同的话)。
是否可以在 Azure Pipeline 中获取扩展提交消息?
我想出了另一种方法来获得我需要的东西。以下行(在 powershell 中)将最近的提交消息分配给 $commitMessageFull
作为字符串数组,每行一个字符串。
$commitMessageFull = git log -1 --pretty=%B
然后您可以将第一行和扩展消息分开:
$first, $extended = $commitMessageFull
$first
变量现在包含一个字符串,它是提交消息的第一行,$extended
包含一个字符串数组,它是剩余的行。
在 AppVeyor 中,我们使用 APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED
environment variable 获取 Git 提交消息的扩展部分,但我在 Azure Pipelines 中看不到等效项。
如果我创建一个包含 printenv | sort
的 bash
步骤来查看我的 YAML 管道中的所有可用环境变量,那么输出表明 BUILD_SOURCEVERSIONMESSAGE
仅包含提交消息,并且不存在 EXTENDED
等价物。我也看不到文档中的任何内容。我们的存储库托管在 GitHub 中,而不是托管在 Azure DevOps 中(如果这有所不同的话)。
是否可以在 Azure Pipeline 中获取扩展提交消息?
我想出了另一种方法来获得我需要的东西。以下行(在 powershell 中)将最近的提交消息分配给 $commitMessageFull
作为字符串数组,每行一个字符串。
$commitMessageFull = git log -1 --pretty=%B
然后您可以将第一行和扩展消息分开:
$first, $extended = $commitMessageFull
$first
变量现在包含一个字符串,它是提交消息的第一行,$extended
包含一个字符串数组,它是剩余的行。