如何从 git post-commit 挂钩运行 cmd [英] how do I run cmd from the git post-commit hook
问题描述
我想在我的私人项目上创建一个微型 ci 循环,并且正在考虑是否可以在 batfile 中运行 msbuild,我可以在 cmd 窗口上获得彩色反馈并自动构建.因此,如果我可以从 post-commit 钩子中触发 bat,我想这是可能的.这不可能是一个新想法,但我在谷歌上找不到任何例子.
I want to have a miniature ci loop on my private projects and was thinking if I could run msbuild inside a batfile I could have colorized feedback on the cmd window and automate the build. So if I could just trigger the bat from the post - commit hook I guess it would be possible. It can´t possible be a new idea but I can´t find any examples on google.
任何意见将不胜感激:)
any input would be appreciated :)
推荐答案
从提交后挂钩调用 .bat
文件不需要任何魔法.
Calling the .bat
file from your post-commit hook doesn't require any magic.
将 .git/hooks/post-commit.sample
中的 post-commit 钩子模板重命名为 .git/hooks/post-commit
并在其中调用批处理文件只需编写批处理文件的名称:
Rename the post-commit hook template in .git/hooks/post-commit.sample
to .git/hooks/post-commit
and call the batch file within by simply writing the name of the batch file:
#!/bin/sh
path/to/batchfile.bat
请注意,git hook 的工作目录是 你的 repo 的根目录.如果您使用 .bat
文件的相对路径,则必须考虑到这一点.
Please note that the working directory for the git hook is the root directory of your repo. If you use relative paths to your .bat
file, you have to take this into account.
这篇关于如何从 git post-commit 挂钩运行 cmd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!