Git提交后钩子:如何在Windows中启动bat文件 [英] Git post-commit hook: How to start a bat-file in Windows
问题描述
我有一个名称为jenkins.bat
的蝙蝠文件,可以在jenkins服务器上开始构建进程.
i having a bat-file with name jenkins.bat
to start building process on a jenkins server.
现在,我想在git中作为提交后的钩子执行此bat文件.
Now I want to execute this bat-file as post-commit-hook in git.
因此在文件夹/.git/hooks
中创建了以下文件post-commit
:
Therefore a created following file post-commit
in the folder /.git/hooks
:
#!/bin/bash
/.git/hooks/jenkins.bat
但是每次提交代码更改为git时,eclipse每次都会抛出异常!我错过了什么吗?
But eclipse throws me every time an exception when commiting code changes to git! Did I miss something?
推荐答案
您需要使用绝对路径或相对路径
You need to use either an absolute or relative path
-
绝对值:/c/...
absolute: /c/...
,或者,如所注释的,相对的,意味着不是以/
or, as commented, relative, meaning not starting with a /
./jenkins.bat
假定您的提交后挂钩是可执行的,并且在<repo>/.git/hooks
文件夹中的jenkins.bat
所在位置.
Assuming your post-commit hook is executable, and in the <repo>/.git/hooks
folder, where your jenkins.bat
appears to be.
Paul 提到
当批处理文件位于hooks目录中时,执行 Doing 这篇关于Git提交后钩子:如何在Windows中启动bat文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!./jenkins.bat
不会 起作用:错误.
这是因为钩子的工作目录.
./jenkins.bat
does not work when the batch file is in the hooks directory: you will get a "no such file
" error.
This is because of the hook's working dir.