我们正在迁移为我们的 CI 管道使用 Cake 构建脚本,并且在我们的构建过程中,我们使用来自 command 的输出识别具有提交计数的构建git rev-list --all –count
。
在 Cake 中是否有一种本机方法,而无需使用 git 命令行?
虽然对此没有内置别名,但 Cake 有一个名为Cake.Git的插件,它使您能够实现您所要求的。
示例用法:
#addin nuget:?package=Cake.Git
DirectoryPath repoPath = Directory("path to repo");
var commits = GitLog(repoPath, int.MaxValue);
Information("Number of commits: {0}", commits.Count);
会输出类似的东西
Number of commits: 1539
只是想指出一个替代方案......
我和 Cake 本身使用一个名为GitVersion的工具来根据 git 提交历史来断言语义版本号。只是想指出它,以防它可能非常适合您的管道。