【问题标题】:Git post-commit hook: How to start a bat-file in WindowsGit post-commit hook:如何在 Windows 中启动 bat 文件
【发布时间】:2017-10-11 21:29:54
【问题描述】:

我有一个名为 jenkins.bat 的 bat 文件来开始在 jenkins 服务器上构建进程。

现在我想在 git 中将这个 bat 文件作为 post-commit-hook 执行。

因此在文件夹/.git/hooks中创建了以下文件post-commit

#!/bin/bash
/.git/hooks/jenkins.bat

但是每次向 git 提交代码更改时,eclipse 都会抛出异常!我错过了什么吗?

【问题讨论】:

  • 去掉.git之前的前导/

标签: windows git batch-file jenkins


【解决方案1】:

您需要使用绝对路径或相对路径

  • 绝对:/c/...

  • 或者,正如评论的那样,相对的,意思是不以/开头

      ./jenkins.bat
    

假设您的 post-commit 挂钩是可执行的,并且在您的 jenkins.bat 所在的 <repo>/.git/hooks 文件夹中。


正如Paul 提到in the comments

当批处理文件位于 hooks 目录中时,./jenkins.bat 不会工作:您将收到“no such file”错误。
这是因为hook's working dir

【讨论】:

  • “可执行文件”是什么意思?
  • 我必须指出,当批处理文件位于 hooks 目录中时,执行 ./jenkins.bat 确实 not 起作用:您将收到“没有这样的文件”错误。这是因为hook's working dir
  • @Paul 谢谢,好点子。我已将您的评论包含在答案中以提高知名度。
  • 还有@user3133542:在 Windows 上,什么都没有。这可能是对在 Unix 中如何使用 chmod 使脚本可执行的参考。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-06
  • 2019-01-23
  • 2013-01-07
  • 1970-01-01
  • 2016-07-11
  • 1970-01-01
  • 2023-04-11
相关资源
最近更新 更多