Closed gnustavo closed 4 years ago
this issue here is you need to use the new API for it to trigger inside the Bitbucket UI
public RepositoryHookResult preUpdate(@Nonnull PreRepositoryHookContext context, @Nonnull RepositoryHookRequest request) {
I'm rewriting external hook.. and see if i can get it to work using https://bitbucket.org/atlassian/bitbucket-server-example-plugins/src/9e1728cfab668ab0f8c1c4ada507994dffa5b5e6/hooks-guide/src/main/java/com/atlassian/bitbucket/server/examples/BranchInReviewHook.java?at=master&fileviewer=file-view-default
Cool! I'm glad to know it.
@gnustavo I've copied much from https://github.com/ngsru/atlassian-external-hooks/pull/56 to make it work for me
What's the current status of this? We have a particular External Pre Receive Hook. When editing a file in the browser, I can see that it does successfully block a commit, as there is a message added to the log file:
hook 'external-pre-receive-hook' vetoed the push request
However in the browser itself, the Commit file popup stays up indefinitely with a spinning icon.
If I check on the server, the hook script has definitely stopped running and returned an error code. Why then doesn't the stderr message from the hook script appear in the browser?
@latitude37s: which version of plugin do you use?
We're using Bitbucket v5.13.1 and External Hooks v4.4-1. Especially since https://jira.atlassian.com/browse/BSERV-9749 was resolved, we were expecting to see the error messages from the bash script shown in the browser, the same as when committing from the command line.
@latitude37s: thanks, let me see what's wrong with it. I will let you know about results.
@latitude37s: well it seems like bug in Bitbucket itself.
When I try to reproduce issue I indeed see described behavior, but when I open Inspector in browser, I see:
a) JavaScript error:
TypeError: str.replace is not a function
b) In Network tab I'm able to see:
{
"errors": [
{
"context": null,
"message": "File editing canceled for 'add_file/add_file.txt' on 'master'.",
"exceptionName": "com.atlassian.bitbucket.hook.repository.RepositoryHookVetoedException",
"details": [
"Push rejected by External Hook\nERROR\n"
],
"trigger": {
"id": "file-edit",
"abortOnFirstVeto": false
}
}
]
}
ERROR
in response is string which I return from bash script.
So my conclusion is that it's some problem in Bitbucket's UI itself.
Are you able to create ticket in Bitbucket bug tracker?
@seletskiy thanks very much for investigating. I will chase Atlassian support on this.
Update: Atlassian accepted this issue as a bug: https://jira.atlassian.com/browse/BSERV-11168.
@latitude37s: great, thanks for the update!
This Bitbucket issue was Closed: Fixed with fix version 5.15.0 but the problem still exists on 6.3.6. Basically we don't see any commit range in the hook input for UI edits. What are your thoughts?
Nevermind - I just upgraded to the latest External Hooks and it fixed the problem. :)
I had to disable Bitbucket's online editing feature because it doesn't invoke our pre/post-receive hooks. However, the issue [BSERV-9521|https://jira.atlassian.com/browse/BSERV-9521] was closed suggesting that Bitbucket 5.0 implements a new hook API which also invokes hooks when a file is edited or created in the browser.
Would you consider this as an improvement? Without this I can't enable Bitbucket's online editing feature.
Thanks!