Using Atlassian Labs POST-Receive WebHooks generate 500 server error

Hi,

I am trying to use the Post-Receive Webhooks from Atlassian Labs.  However it does not seem to POST anything and returns a 500 server error:

2017-07-19 08:17:31,657 INFO [WebHookProcessor:thread-1] c.a.b.p.h.i.RequestFactoryWebHookProcessorWorker Invalid response from hook 'http://xxxMyServerNamexxx:8080/bitbucket-hook/', repository ID '32', status: '500' / 'Server Error'
2

I am using another add-on Push Email Notifier Hook which works perfectly.

Ultimately I would like to notify jenkins so I might have a workaround using  https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview but I would like to know why the Atlassian Labs POST-Receive WebHooks does not work.

Regards

 Ben

 

1 answer

0 vote

Hi Ben,

I have used this plugin on several occasions and from my testing it works right out of the box without any additional configuring.


To confirm that the hook is firing I did the following:


- After pushing a commit to my remote repo I parsed the $BITBUCKET_HOME/log/atlassian-bitbucket.log file for mentions of the URL I entered in the plugin's settings:


grep nh.payload.com /var/atlassian/application-data/bitbucket/log/atlassian-bitbucket.log

2017-07-20 19:23:52,471 INFO [WebHookProcessor:thread-1] nhansberry @1XHKI4Ox1163x769x0 192.168.10.1 "POST /scm/hel/hello.git/git-receive-pack HTTP/1.1" c.a.b.p.h.i.RequestFactoryWebHookProcessorWorker Unable to do post to 'http://nh.payload.com' hook for repository ID: '1', reason: java.net.UnknownHostException: nh.payload.com: Name or service not known

com.atlassian.sal.api.net.ResponseException: java.net.UnknownHostException: nh.payload.com: Name or service not known

Caused by: java.net.UnknownHostException: nh.payload.com: Name or service not known
Since I didn't set up a server to digest the payload I got a "Name or service not known" error but the post reecive hook did fire.

- To take this one step further I set up a local webserver (using https://dashboard.ngrok.com) and monitored the interface while pushing a commit to the remote repository. Since the web server was bare bones, the payload wasn't digested but the POST request was received:


POST / 502 Bad Gateway
I was also able to find the corresponding POST request in the Bitbucket Server log to confirm that the hook did fire:
2017-07-20 21:15:36,119 INFO [WebHookProcessor:thread-2] nhansberry @1XHKI4Ox1275x983x0 192.168.10.1 "POST /scm/hel/hello.git/git-receive-pack HTTP/1.1" c.a.b.p.h.i.RequestFactoryWebHookProcessorWorker Invalid response from hook 'http://1a068da9.ngrok.io', repository ID '1', status: '502' / 'Bad Gateway'

I hope this information is helpful!

Hi Nathaniel,

Thank you for your answer.  I am not sure it is to do with the plugin itself rather than the all setup. Unfortunately I am a bit of a novice using these tools and I am constrained by environment: I am using a single Windows server (2012 R2) to host my Bitbucket server and my Jenkins CI server.

As you can see my plan was to use the "old" Bitbucket plugin with Jenkins as I have seen it working on a Youtube video but with Bitbucket Cloud.  I thought I could emulate this with the ost-Receive Webhooks from Atlassian Labs for Bitbucket server.

After more attempts, I have a high suspicion it is a problem of network settings on my server coupled with some credentials settings on the Jenkins side that cause the problem.

Unfortunately I have not been able to solve them and have started to use an SSH connection to pull the code from Bitbucket and use the Nerdwin add-on.

It is not a great solution as this add-on is on its way :(

Regards


Ben

Hi Ben,

 

I am glad you found somewhat of a work around.

 

The main take away from my initial response is that you'll be able to see if the plugin is firing/working by parsing the $BITBUCKET_HOME/log/atlassian-bitbucket.log file after pushing a commit to a repo.

I did this on a linux box by running the following command which searches the log for the URL I entered into the plugins setting:

 

grep nh.payload.com /var/atlassian/application-data/bitbucket/log/atlassian-bitbucket.log

 

Here the URL is nh.payload.com but you will replace this with the Jenkins server you are sending the request to.

In the output I provided in my last respone, we see the WebHook Processor Thread for each test:

WebHookProcessor:thread-1

WebHookProcessor:thread-2

 

Look for these threads in your logs to confirm the plugin is working.

That will narrow the scope of your troubleshooting and you can focus on the network settings and credentials that you mentoined.

 

I hope this information is helpful!

 

-Nate

Hi Nathaniel,

I don't seem to be able to insert large chunks of my log file in my answer but yes I can see the threads you mention.  However the one regarding the bitbucket server comes back like this:

2017-07-19 08:17:31,657 INFO [WebHookProcessor:thread-1] c.a.b.p.h.i.RequestFactoryWebHookProcessorWorker Invalid response from hook 'http://MyServerName:8080/bitbucket-hook/', repository ID '32', status: '500' / 'Server Error'
2017-07-19 08:17:31,923 ERROR [search-indexing:thread-1] c.a.b.s.i.i.e.DefaultIndexEventWorker Indexing - Failed for repository CORE/cisetuprep (id: 32) with error: java.net.ConnectException: Connection refused: no further information
java.util.concurrent.ExecutionException: java.net.ConnectException: Connection refused: no further information
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at rx.internal.operators.OnSubscribeToObservableFuture$ToObservableFuture.call(OnSubscribeToObservableFuture.java:74)
at rx.internal.operators.OnSubscribeToObservableFuture$ToObservableFuture.call(OnSubscribeToObservableFuture.java:43)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable.unsafeSubscribe(Observable.java:8171)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:232)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:142)
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:54)
at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:46)
at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:35)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable$2.call(Observable.java:162)
at rx.Observable$2.call(Observable.java:154)
at rx.Observable.subscribe(Observable.java:8264)
at rx.Observable.subscribe(Observable.java:8231)
at rx.Observable.subscribe(Observable.java:8035)
at com.atlassian.bitbucket.search.internal.indexing.event.IndexEventQueueProcessor.processEvent(IndexEventQueueProcessor.java:233)
at com.atlassian.bitbucket.search.internal.indexing.event.IndexEventQueueProcessor.processEvents(IndexEventQueueProcessor.java:214)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.lang.Thread.run(Thread.java:745)
... 1 frame trimmed
Caused by: java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:173)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:147)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:350)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:191)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
at java.lang.Thread.run(Thread.java:745)
2017-07-19 08:17:31,923 INFO [search-indexing:thread-1] c.a.b.s.i.i.e.IndexEventQueueProcessor Worker instructed us to retry QueuedEvent{event=RepositoryContentModifiedIndexEvent{repositoryId=32}, retries=0}, retrying in 60 s

 

Regards

 

Ben 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,749 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you