我在接收后 Hook 和 Jenkins 集成方面遇到问题。 我在 GIT 存储库的 hooks 目录中添加了一个名为 post-receive 的文件。文件内容为:
#!C:/Program\ Files/Git/usr/bin/sh.exe
echo "Post-receive started..."
curl.exe --user Jakob:tempPassword --url "http://localhost:8080/job/TestJob/build?token=ebcc64cb8315211c5287b20b3fdd7190"
echo "Post-receive ended..."
在 Jenkins 方面,我有一份关于这个 token 的工作。 我在 Windows 10 计算机上运行 Jenkins 和 GIT-repos。
现在解决问题了。如果我在 git bash shell 本地执行上述命令,则所有内容都会执行并启动 Jenkins 构建。一切都很好。
如果我将某些内容提交/推送到 GIT-repo,我可以看到 post-receive-hook 已执行(正如我在 tortoisegit 窗口中看到的那样),但 jenkins 作业未执行!
问题可能是什么?
最佳答案
我已经为此苦苦挣扎了两天,在发布我的问题后,我找到了解决方案。我重新配置 Jenkins 以使用机器中 NIC 的 IP 地址(而不是我使用的 localhost,例如 192.168.1.55)并将 sh 脚本更新为:
#!C:/Program\ Files/Git/usr/bin/sh.exe
echo "Post-receive started..."
curl.exe --user Jakob:tempPassword --url "http://192.168.1.55:8080/job/TestJob/build?token=ebcc64cb8315211c5287b20b3fdd7190"
echo "Post-receive ended..."
现在一切正常了!
关于git - Windows 上的接收后 Hook 和 Jenkins,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51428859/