Post Receive Hook not Firing for Pushed Tags
Created by: brad-jones
Okay I'll just make it very clear I am by no means a ruby dev and I had a few attempts at installing gitlab before I got it working so please feel free to point out any noob mistakes I may have made. I am also fairly new to git in general so maybe I am not "tagging" correctly.
For some reason my web hooks do not fire when a new tag is pushed. My web hooks work fine when any other branch is pushed just not a tag. The job doesn't even appear in Resque.
According to the post_receive hook it should work. "# For every branch or tag that was pushed, create a Resque job in redis."
I am a PHP dev by day so naturally I added a PHP script into the hook. I passed the same arguments $reponame $oldrev $newrev $ref $GL_USER to my php script. And it worked, my script was called when a tag or branch was pushed. Whereas the resque job is only added when the push is not for a tag.
My post_recieve file now looks like this:
#!/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.
pwd=`pwd`
reponame=`basename "$pwd" | sed s/\.git$//`
env -i redis-cli rpush "resque:queue:post_receive" "{\"class\":\"PostReceive\",\"args\":[\"$reponame\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]}" > /dev/null 2>&1
/usr/bin/php /srv/custom-gitlab-hooks/test.php $reponame $oldrev $newrev $ref $GL_USER
done
Here is what my php script collected on 2 pushes one on the master branch and one for a new tag.
Array
(
[0] => /srv/custom-gitlab-hooks/test.php
[1] => example1
[2] => 85b820ff8c5e603cd3e78df07a2127129b18a1a7
[3] => a021431e365f617c888f599174b5f67d2be5f4b4
[4] => refs/heads/master
[5] => bj_gravit_com_au_1352425563
)
Array
(
[0] => /srv/custom-gitlab-hooks/test.php
[1] => example1
[2] => 0000000000000000000000000000000000000000
[3] => a021431e365f617c888f599174b5f67d2be5f4b4
[4] => refs/tags/testabc
[5] => bj_gravit_com_au_1352425563
)
Could it be possible that resque does not like the zero $oldrev value?
Also just for reference when I do push a tag it does appear in gitlab, it's not as though the tag is corrupt or isn't working at all.
Anyway now that I have added in my php hook directly, bypassing resque all together I am getting done what I needed to get done. So I am in no great rush but thought I would report this all the same, in the case that it is some weird bug in the ruby code somewhere.