Git提交后钩子:如何在Windows中启动bat文件 [英] Git post-commit hook: How to start a bat-file in Windows

查看:197
本文介绍了Git提交后钩子:如何在Windows中启动bat文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名称为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目录中时,执行./jenkins.bat不会 起作用:错误.
这是因为
钩子的工作目录.

Doing ./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.

这篇关于Git提交后钩子:如何在Windows中启动bat文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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