git - Windows 上的接收后 Hook 和 Jenkins

标签 git jenkins push hook

我在接收后 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 作业未执行!

enter image description here

问题可能是什么?

最佳答案

我已经为此苦苦挣扎了两天,在发布我的问题后,我找到了解决方案。我重新配置 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/

相关文章:

git rm -r some-file => 如果路径不存在,则 git 以 1 退出

java - Jenkins GitPlugin - 如何找出预构建 merge 失败的原因?

git - Jenkins 报告的未知选项 git config --local

git - Jenkins 和 Git 配置问题

javascript - AngularJS Controller 内的数组未初始化

git bash 配置问题

asp.net - Nuget 不更新 ASP.NET 网站中的包引用

java - 当我们使用 git merge 或分支来掌握时,重构是否会发生在所有类上

Git 恢复一个大的 PUSHed 文件

firebase - Flutter - 在没有 firebase 身份验证的情况下将 firebase 通知推送给特定用户