I am trying to replace my post-receive hook, automatically generated by GitLab, with a new file that allows mail support and therefore should be called "post receive".
This is the previous version of my file:
#!/usr/bin/env bash # This file was placed here by GitLab. It makes sure that your pushed commits # will be processed properly. while read oldrev newrev ref do # For every branch or tag that was pushed, create a Resque job in redis. repo_path=`pwd` env -i redis-cli rpush "resque:gitlab:queue:post_receive" "{\"class\":\"PostRe ceive\",\"args\":[\"$repo_path\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]} " > /dev/null 2>&1 done
When I replace this file with a new one that includes the above lines at the end of the file, GitLab says: “The project has an invalid post-receive file” in the administration area, but the letters are sent correctly.
You know how to deal with this issue of multiple support after receiving. At the moment, I don’t know if the specific part of the gitlab file is executed correctly.
Thanks for the help!
Update:
Scripts in folders are now called using the solution below (pull request). But I don’t understand why the standard "post-receive-email" script does not send any emails if it is included in the directory. It works great if it is called immediately after sending.
I don’t know why I need to change the order, but the following works for me (even I don’t know if the resque jobs are created correctly:
#!/usr/bin/env bash repo_path=`pwd` if [ -d hooks/post-receive.secondary.d ]; then for i in hooks/post-receive.secondary.d/* do [ -x "$i" ] || continue # call the hooklet with the same arguments we got path=$repo_path"/"$i "$path" " $@ " || { # hooklet failed; we need to log it... echo hooklet $i failed perl -I$GL_BINDIR -Mgitolite -e "log_it('hooklet $i failed')" # ...and send back some non-zero exit code ;-) exit 1 } done fi while read oldrev newrev ref do # For every branch or tag that was pushed, create a Resque job in redis. env -i redis-cli rpush "resque:gitlab:queue:post_receive" "{\"class\":\"PostReceive\",\"args\":[\"$repo_path\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]}" > /dev/null 2>&1 done exit 0
git gitlab
John rumpel
source share