reconquest / atlassian-external-hooks

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

After adding an "External Async Post Receive Hook", any push LOOPS ENDLESSLY #58

Closed chahn1138 closed 4 years ago

chahn1138 commented 6 years ago

Atlassian Bitbucket v4.14.4

From my own repos setting page:

/users/christopher.hahn/repos/hooktest/settings/hooks this is the text from the hook config web-dialog: =============================== External Async Post Receive Hook Executable: basictest.sh Path to executable to run. Safe mode [X] Look for hooks only in safe dir Hooks will be searched only in /external-hooks/ =============================== The script: /var/atlassian/bitbucket-home/external-hooks/basictest.sh is a classic, off the net: =============================== #!/bin/bash ( echo "Script name: $0" echo "Positional arguments: ${@}" echo "STASH_USER_NAME: $STASH_USER_NAME" echo "STASH_USER_EMAIL: $STASH_USER_EMAIL" echo "STASH_REPO_NAME: $STASH_REPO_NAME" echo "STASH_IS_ADMIN: $STASH_IS_ADMIN" while read from_ref to_ref ref_name; do echo "Ref update:" echo " Old value: $from_ref" echo " New value: $to_ref" echo " Ref name: $ref_name" echo " Diff:" git show $from_ref..$to_ref | sed 's/^/ /' done ) | tee -a /tmp/external-hooks-test.log =============================== The script is 755 and runs fine from the command line. BUT, when I push any change, the console loops over the same output: =============================== $ git push newbranch Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 285 bytes | 0 bytes/s, done. Total 3 (delta 1), reused 0 (delta 0) remote: remote: Create pull request for newbranch: remote: https://XXXXX/users/christopher.hahn/repos/hooktest/compare/commits?sourceBranch=refs/head... remote: remote: remote: Create pull request for newbranch: remote: https://XXXXX/users/christopher.hahn/repos/hooktest/compare/commits?sourceBranch=refs/head... remote: remote: remote: Create pull request for newbranch: remote: https://XXXXX/users/christopher.hahn/repos/hooktest/compare/commits?sourceBranch=refs/head... remote: remote: Create pull request for newbranch: remote: https://XXXXX/users/christopher.hahn/repos/hooktest/compare/commits?sourceBranch=refs/head... remote: Killed by signal 2. fatal: The remote end hung up unexpectedly error: error in sideband demultiplexer To ssh://git@XXXXX:7999/~christopher.hahn/hooktest.git 35734f5..8544dec newbranch -> newbranch =============================== Has anyone else seen this?
chahn1138 commented 6 years ago

Pardon my attempt to use ascii to format the thing....wow

chahn1138 commented 6 years ago

More Data...just added as a comment on the related card:

I have queries on two different boards, the Atlassian Community and the Github site of the plugins creators. No responses yet.

I am now testing using the "safe dir" and the simplest of scripts:

[stash@XXXXX 765]$ /var/atlassian/bitbucket-home/external-hooks/test.sh IN SCRIPT: Test

[stash@XXXXX 765]$ cat !$ cat /var/atlassian/bitbucket-home/external-hooks/test.sh

!/bin/sh

echo "IN SCRIPT: Test" exit 0

Note the simplicity of the script.

The error seen in the log when one of these pushes hangs: 2017-10-06 08:28:48,520 ERROR [AtlassianEvent::thread-3] christopher.hahn @16MC444x508x1769362x0 fcszye X.X.X.X SSH - git-receive-pack '~christopher.hahn/hooktest.git' c.n.s.e.hook.ExternalPreReceiveHook Error running [/var/atlassian/bitbucket-home/external-hooks/test.sh, ] in /var/atlassian/bitbucket-home/shared/data/repositories/765 java.io.IOException: Broken pipe

2017-10-06 08:38:19,894 ERROR [AtlassianEvent::thread-3] christopher.C366x516x1773236x0 1visy70 X.X.X.X SSH - git-receive-pack '~christopher.hahn/hooktest.git' c.n.s.e.hook.ExternalPreReceiveHook Error running [/var/atlassian/bitbucket-home/external-hooks/test.sh, ] in /var/atlassian/bitbucket-home/shared/data/repositories/765 java.io.IOException: Stream closed

chahn1138 commented 6 years ago

I got my own answer: I had first tried to get this working using a script in the traditional location...the repos hook directory. Well, I had left a copy of some version of my script down on the post-receive.d sub-directory. What I was seeing that that "second script" being run, over and over and over. The idea here is that one should just stay away from using hooks with Bamboo unless you are using a plugin to drive them.