tobi
tobi

Reputation: 863

Why does the post-receive hook not work?

my post-receive hook does not work. I checked that:

- it is named post-receive and resides in server's repos hooks folder
- it is executable and the owner is git
- I can execute it manually as user git

Within the post-receive script I call jenkins to make a build. But it looks, like the script is not executed at all. What could go wrong here?

[toki@v22018076590769xxx ~]$ cd /opt/git/project.git/hooks/
[toki@v22018076590769xxx hooks]$ ls -l
insgesamt 44
-rwxrwxr-x. 1 root git  452 14. Jul 19:59 applypatch-msg.sample
-rwxrwxr-x. 1 root git  896 14. Jul 19:59 commit-msg.sample
-rwxrwxrwx. 1 git  git  204 15. Jul 16:05 post-receive
-rwxrwxr-x. 1 root git  189 14. Jul 19:59 post-update.sample
-rwxrwxr-x. 1 root git  398 14. Jul 19:59 pre-applypatch.sample
-rwxrwxr-x. 1 root git 1704 14. Jul 19:59 pre-commit.sample
-rwxrwxr-x. 1 root git 1239 14. Jul 19:59 prepare-commit-msg.sample
-rw-rw-r--. 1 root git 1348 14. Jul 19:59 pre-push.sample
-rwxrwxr-x. 1 root git 4951 14. Jul 19:59 pre-rebase.sample
-rwxrwxr-x. 1 root git 3611 14. Jul 19:59 update.sample
[toki@v22018076590769xxx hooks]$ 

Content of post-receive

[toki@v22018076590769xxx hooks]$ cat post-receive 
#!/bin/sh
echo "starting post-commit hook"

/usr/bin/curl --user xxxxx:xxxxxx -s \
http://v22018076590769xxx.powersrv.de:8080/jenkins/job/Weasy/build?token=build_weasy

echo "post-commit hook finihed"

[toki@v22018076590769xxx hooks]$

Upvotes: 1

Views: 270

Answers (1)

tobi
tobi

Reputation: 863

found it! there was a bad error in the file structure:

I put the hook to /opt/git/project.git/hooks/ , but it should reside in /opt/git/project.git/.git/hooks/

Since I moved the hook to the right place, it works fine!

Upvotes: 1

Related Questions