gpt4 book ai didi

linux - 未触发 Git 提交后 Hook

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:05:14 24 4
gpt4 key购买 nike

我用标准 bash 脚本编写了一个名为 post-commit 的文件(无文件扩展名,可执行文件,由 git 用户拥有)以触发 Jenkins 在另一台服务器上构建并将其放在目录 git/ProjectName/hooks 在我们的远程存储库中。当我以用户 git 手动执行文件时(./post-commit).

Jenkins 构建开始。但是,当我将某些内容推送到存储库时(并且我看到在远程存储库的 Git 日志中进行了提交) post-commit 文件未执行(我通过在中放置 echo 命令进行检查文件)。

为什么 post-commit 文件没有执行?

最佳答案

post-commit Hook 不会在远程执行,因为未在远程上进行提交。

您需要的是服务器上的post-receive Hook 。

https://git-scm.com/book/gr/v2/Customizing-Git-Git-Hooks

Server-Side Hooks In addition to the client-side hooks, you can use a couple of important server-side hooks as a system administrator to enforce nearly any kind of policy for your project. These scripts run before and after pushes to the server.
...
post-receive
The post-receive hook runs after the entire process is completed and can be used to update other services or notify users. It takes the same stdin data as the pre-receive hook. Examples include e-mailing a list, notifying a continuous integration server, or updating a ticket-tracking system – you can even parse the commit messages to see if any tickets need to be opened, modified, or closed. This script can’t stop the push process, but the client doesn’t disconnect until it has completed, so be careful if you try to do anything that may take a long time.

关于linux - 未触发 Git 提交后 Hook ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48283272/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com