您可以在powershell中使用run git命令来获取已更改文件的内容。
下面的命令列出了提交中所有更改的文件。选中此thread以获取更多信息
git diff-tree --no-commit-id --name-only -r $commitID
要显示文件内容,可以使用以下命令。请参阅此thread
git show ${commitId}:$file
azure管道中的整个powershell脚本示例如下:
Set-Location -Path "$(Build.Repository.LocalPath)" #set working folder to git sources folder
$commit = "$(Build.SourceVersion)" #get the commit hash
$files = git diff-tree --no-commit-id --name-only -r $commit #list the changed files
ForEach($file in $files){
$content = git show ${commit}:$file #get the file content
(Invoke-RestMethod ......) # you can then invoke your API To send the file content.
}
选中此site,以了解有关Azure管道中预定义变量的更多信息。
然后,您可以在构建管道中添加powershell任务以在脚本之上运行。
如果要使用webhook进行此操作。您可以参考this simple guide来了解如何创建自己的Webhook服务器。
本文链接:https://www.f2er.com/3111882.html