我在Mac上进行开发,但是我有Windows VM,最终无法运行某些版本。非常简单。我让詹金斯(Jenkins)拉并每天构建该应用程序。
在此脚本中,我需要获取一些元数据。我需要获取git服务器上分支的列表,如果有的话(因为分支可能没有提交),则需要最新提交的元数据。特别是提交者的电子邮件。
通常,在我的Mac上,它很简单:
git branch --all > branches
for b in $(cat branches);
do
git checkout $b
git log --name-status HEAD^..HEAD | grep Author | cut -d"<" -f2 | cut -d">" -f1 > email
echo $b > branch
python buildScript.py $(cat email) $(cat branch)
; done
rm email branch
mv branches old_branches
我注意到的问题是:
在分支的新分支上,git log --name-status
显示了提交,但HEAD ^ .. HEAD未返回任何结果。
grep在Windows Cmd提示中不是有效的cmd。
在Windows Cmd提示中,cut不是有效的cmd。
我可能会找到grep并削减替代方案。
有人可以解释为什么提交不会显示在Windows上吗?是否有内置的Python Utility可以在其中处理所有问题?我没有直接运行bash的问题,但是我认为python可以更加干净,因为我已经在运行python脚本来构建...
编辑:我想要的最终状态是bash脚本(或python脚本),其操作如下:
loop over all branches.
if branch is new since the last time the script was run, and has at least 1 commit
run_a_python_script with the committers email and that branch.
else if there were deleted branches since the last time it was run:
run_another_python_script with the branch
else
nothing happens because this script already ran once.
我将其设置为每10分钟间隔一次。
这很容易在Python或Bash中完成。
相关分类