0

Already viewed the following answers before posting this:

Although the pre-push hook is triggered successfully, the post-receive hook is not. I don't think this is a permission issue because they both have exactly the same rights:

-rwxr-xr-x@  1 Malloc  staff    86 May 10 15:57 post-receive
-rwxr-xr-x@  1 Malloc  staff    90 May 10 15:51 pre-applypatch
-rwxr-xr-x@  1 Malloc  staff    82 May 10 15:51 pre-commit
-rwxr-xr-x@  1 Malloc  staff   153 May 10 16:05 pre-push

Here is the content of the post-receive executable:

#!/bin/sh
echo "post-receive hook successfully triggered"

The following content is put in the pre-push hook:

#!/bin/sh
echo "pre-push hook successfully triggered"

Once I push to remote, the pre-push message is printed to the Terminal but not the post-receive.

Any idea what may be going wrong?

Malloc
  • 15,434
  • 34
  • 105
  • 192
  • 1
    Is your `post-receive` in the local repository? This hook executes on the remote repository. So it runs when the local repository serves as a remote repository, in other words when you push from another repository to this repository. – ElpieKay May 10 '19 at 14:28
  • Did you mean when a pull is done on the repo? Basically no hook, except `pre-push`, is triggered. – Malloc May 10 '19 at 14:42
  • Not a pull. Git repositories are decentralized. A repo can be a client and also a server. Suppose we have two repositories A and B. When you push from A to B, A is the client and B is the server. `pre-push` in A is invoked and `post-receive` in B would be invoked if the push succeeds. When you push from B to A, B is the client and A is the server. `pre-push` in B is invoked and `post-receive` in A is invoked. – ElpieKay May 10 '19 at 14:50
  • Alright, in my case post-receive is not the right hook that I am looking for. Do you know which hook is triggered on A when the push is completed? – Malloc May 10 '19 at 14:54
  • There is no `post-push`-like hook as I know. Why would you want such a hook? – ElpieKay May 10 '19 at 14:55
  • I am trying to trigger a Jenkins job after a push is done on remote. The job is triggered through a POST url. At first I tried to curl the url inside a git hook that get executed on post push. Will try to do that in other way. Thanks for the clarifications :) – Malloc May 10 '19 at 15:06
  • Jenkins has triggers that work as a `post-receive` hook. – ElpieKay May 10 '19 at 15:10
  • Yes, however the problem is that Jenkins is installed in local, tunnelling it through some servers (like ngrok) is blacklisted on the SCM server, which means that it was impossible to hook it. The only solution I had is to call a POST Webhook trigger API installed on Jenkins. – Malloc May 10 '19 at 15:14
  • A post-receive hook has no access to the output stream of the user who started the `git push` operation. In fact, its stdout and stderr are generally just lost—you'll want to use some kind of logging to trace it. – torek May 10 '19 at 17:51
  • Are you using standard git server? I remember that some solutions have their own hook mechanism and some don't implement all functionalities. –  May 13 '19 at 06:54

0 Answers0