Bitbucket Webhook Error 500 on Jenkins

Bitbucket Webhook Error 500 on Jenkins

What does bitbucket webhook do?

When code is pushed to bitbucket, it’s suppose to trigger our Jenkins webhook URL in order to automate the continuous integration process where Jenkins will build and deploy the project.

Then one day it stop working

Bitbucket failed to trigger the automated build at our Jenkins instance. A workaround for this is to setup the Poll SCM to scan for configurable interval time, but that’s not the scope right now.

You can see the history of bitbucket pushes to Jenkins webhook URL (you have to enable the ‘history’ if you want to see the push events history) in bitbucket web. There is some error of response code 500 from Jenkins.

Bitbucket webhook error 500 on Jenkins
Jenkins reponded 500 error for the push!

JSONObject[“username”] not found

It was pretty much clueless from the Jenkins response. Digging at Jenkins (docker container) logs reveals the error of JSONObject[“username”] not found, which is not really helpful.

2020-02-26 13:35:01.105+0000 [id=616616]	WARNING	o.e.j.s.h.ContextHandler$Context#log: Error while serving
net.sf.json.JSONException: JSONObject["username"] not found.
	at net.sf.json.JSONObject.getString(
	at com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor.processWebhookPayload(
	at com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor.processPayload(
	at com.cloudbees.jenkins.plugins.BitbucketHookReceiver.doIndex(
	at java.lang.invoke.MethodHandle.invokeWithArguments(
	at org.kohsuke.stapler.Function$MethodFunction.invoke(

A quick googling on this brings me to this Jenkins issue. Apparently bitbucket has recently deprecated the username attribute and removed the push API. The solution is simple, update the bitbucket plugin 1.1.8 to 1.1.11 and viola it works!

Bitbucket webhook successfully trigger on Jenkins
Bitbucket push is now working!

Leave a Reply

Your email address will not be published. Required fields are marked *