如何从git post-commit钩子运行cmd [英] how do I run cmd from the git post-commit hook

查看:169
本文介绍了如何从git post-commit钩子运行cmd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的私人项目上有一个微型ci循环,并且正在想如果我可以在batfile中运行msbuild我可以在cmd窗口彩色反馈和自动化构建。所以如果我可以从post-commit钩子触发bat,我想这是可能的。它不可能是一个新的想法,但我不能在google上找到任何例子。

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 :)

推荐答案

code> .bat 文件不需要任何魔术。

Calling the .bat file from your post-commit hook doesn't require any magic.

重命名post-commit钩子模板在 .git / hooks / post-commit.sample .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钩子的工作目录是根目录您的库存。如果您使用相对路径到您的 .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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆