Windows 服务器端 post-接收 git 钩子挂起

Windows servier-side post-receive git hook hangs

我在 Apache 服务器上设置了 Git,一切正常。现在我想设置一个 post-receive 挂钩来启动 Jenkins 构建。

脚本我写好了,在服务器上测试没有问题。但是,当我执行 git push 时,它到达 "Total" 行并停止:

C:\develop\.ws\git-repo>git push
Username for 'https://internal.git.repo.com': user
Password for 'https://user@internal.git.repo.com':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 289 bytes | 289.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)

查看服务器,我可以看到脚本已尝试启动,但已挂起并使用了一个核心的 CPU:

由于脚本似乎导致了问题,我只是通过重命名删除 "sample" 扩展名来尝试示例脚本,但表现出相同的行为。所以我将脚本更改为:

#!/bin/sh
exit 0

#!C:/git-2.25.1/bin/sh.exe
exit 0

但还是一样。

怎么回事?

已解决。周末与 IT 人员交谈时,建议是用户习惯 运行 Apache 服务器可能是原因。目前该服务是 运行 使用 "Local System Account"。一旦更改为实际用户,sh.exe 将不再挂起。