reconquest / atlassian-external-hooks

External Hooks plugin for Atlassian Bitbucket
https://external-hooks.reconquest.io
Other
44 stars 37 forks source link

External hooks configuration not working #91

Open Ashokg6 opened 5 years ago

Ashokg6 commented 5 years ago

Hi ,

I'm using below versions , I have copied my script to /external-hooks/ directory and given execute flag as well bit its not working .

Version : Atlassian Bitbucket v5.8.0 External Hooks : Version:4.7-1

Stash home : /opt/bitbucket/home itbucket@l42-icx-nexus-01:/tmp$ echo $BITBUCKET_HOME /opt/bitbucket/home/ bitbucket@l42-icx-nexus-01:/tmp$ bitbucket@l42-icx-nexus-01:/tmp$ ls -ltr /opt/bitbucket/home/external-hooks/test.sh -rwxrwxr-x 1 bitbucket bitbucket 651 Jun 24 02:49 /opt/bitbucket/home/external-hooks/test.sh bitbucket@l42-icx-nexus-01:/tmp$ external-plugin

Ashokg6 commented 5 years ago

I'm blocked since many days now , so please help on the same .

seletskiy commented 5 years ago

@Ashokg6: from what can be seen from the screenshot you've enabled Look for hooks only in safe dir option.

When using this option Executable path should be specified relative to the $BITBUCKET_HOME/external-hooks, e.g. to the /opt/bitbucket/home/external-hooks/ in your case.

Try to specify just test.sh as Executable while having [x] Look for hooks only in safe dir checked.

Ashokg6 commented 5 years ago

@seletskiy , Thanks for looking it . I have made a change as below but still its not working .

First I changed only test.sh ---x--x--x 1 bitbucket bitbucket 651 Jun 24 02:49 external-hooks/test.sh

It did not worked , then I changed parent directory as well . d--x--x--x 2 bitbucket bitbucket 4096 Jun 24 05:53 external-hooks/

My bitbucket home :

bitbucket@l42-icx-nexus-01:~/home$ cat ~/install/atlassian-bitbucket-5.8.0/bin/set-bitbucket-home.sh

One way to set the BITBUCKET_HOME path is here via this variable. Simply uncomment it and set a valid path like

/bitbucket/home. You can of course set it outside in the command terminal; that will also work.

# if [ -z "$BITBUCKET_HOME" ]; then BITBUCKET_HOME=/opt/bitbucket/home/ fi

Bitbucket home also correct , I don't know why its not accepting .

Ok leave it the safe directory option , even I copy the script in some other location and should not checked the option "look for a safe directory" that also not working when i tried a push .

seletskiy commented 5 years ago

@Ashokg6 now your permissions doesn't seem to be correct (missing r flag):

---x--x--x 1 bitbucket bitbucket 651 Jun 24 02:49 external-hooks/test.sh d--x--x--x 2 bitbucket bitbucket 4096 Jun 24 05:53 external-hooks/

File and directory should be at least readable. Please run chmod -R ug+r /opt/bitbucket/home/external-hooks.

Ashokg6 commented 5 years ago

@seletskiy ,

Thanks for the reply , I have tried , but still not working . dr-xr-x--x 2 bitbucket bitbucket 4096 Jun 24 05:53 external-hooks r-xr-x--x 1 bitbucket bitbucket 651 Jun 24 02:49 test.sh

Even without this safe directory option also its not working .

I'm suspecting something related to version incompatibility . Version : Atlassian Bitbucket v5.8.0 External Hooks : Version:4.7-1

Is there any issue with versions ?

BR Ashok

seletskiy commented 5 years ago

@Ashokg6 you can try to update External Hooks to 4.8-3, which is latest version that has compatibility with BB v5.8.0, but even with 4.7-1 it should work.

Can you try following options:

Ashokg6 commented 5 years ago

I did not get the update option to this plugin , may be i'm using evaluation licenses for POC . Actually I have two bitbucket instances 1 . POC server which I'm working right now , its in trail license 2 . Production server in GCP . Before implementing the feature in Production I need to test this POC and then deploy to the production instance .

Ashokg6 commented 5 years ago

I will try to update and see ..

Ashokg6 commented 5 years ago

I have updated the plugin to 4.8-3 and tried even though i'm getting the same issue . now i can see some log there

[ssh-scm-request-handler] ashok.gunduboina @GMZ0U6x229x166x0 1r8gds6 10.198.132.100 SSH - git-receive-pack '/icx/hook_test.git' c.a.s.i.s.g.p.ssh.SshReceivePack ICX/hook_test[82]: Git hooks have not been called. Please verify that the hooks are configured correctly - see https://confluence.atlassian.com/display/BITBUCKETSERVERKB/Git+hook+scripts+are+not+executing?utm_campaign=in-app-help&utm_medium=in-app-help&utm_source=stash for details

seletskiy commented 5 years ago

@Ashokg6 well, according to link in log entry you have a problem with BB installation itself, since its system files are missing (pre- and post-receive hook scripts). It's not related to External Hooks plugin. You need to follow guide linked there to resolve problem.

Ashokg6 commented 5 years ago

@seletskiy , oh is it ? I will follow then . thanks

Ashokg6 commented 5 years ago

@seletskiy I have launched one more server and did a fresh installation, there also getting the same issue . I'm suspecting there might be issue with setting up hook , its always saying that executable flag does not exist .

do you have any steps to configure other than plugin documentation please share me .

Ashokg6 commented 5 years ago

Bitbucket server : 6.2.0 Plugin version : 6.3.1-1 BITBUCKET_HOME="/var/atlassian/application-data/bitbucket"

ls -al dr-xr----- 2 atlbitbucket atlbitbucket 4096 Jul 3 03:10 external-hooks

ls -ltra external-hooks/test.sh -r-xr----- 1 atlbitbucket atlbitbucket 60 Jul 3 03:10 external-hooks/test.sh

I have tried many combinations of permissions but still getting issues , executable flag not found and executable does not exist

Ashokg6 commented 5 years ago

atlbitbucket@l42-re-jenkins2:~$ cat /opt/atlassian/bitbucket/6.2.0/bin/set-bitbucket-home.sh

One way to set the BITBUCKET_HOME path is here via this variable. Simply uncomment it and set a valid path like

/bitbucket/home. You can of course set it outside in the command terminal; that will also work.

# if [ -z "$BITBUCKET_HOME" ]; then BITBUCKET_HOME="/var/atlassian/application-data/bitbucket" fi

I was suspecting this home directory , but in this i have set home like this .

Is there any default bitbucket home ? that system will define automatically ?

seletskiy commented 5 years ago

@Ashokg6 First, try to check that hook template files exists in $BITBUCKET_HOME/data/repositories/<repo_id>/hooks.

If you can't see any, try to setup them by copying the template hooks files from $BITBUCKET_HOME/shared/config/git/templates/hooks/ into the hooks directory of the repository ($BITBUCKET_HOME/data/repositories/<repo_id>/hooks) and setting the ownership to bitbucket. Make sure that they have executable and read flags set for bitbucket user and group.

seletskiy commented 4 years ago

@Ashokg6 is this issue resolved on your side?