How to use Bitbucket Server 5.4 webhooks with Jenkins crumbs

With version 5.4 of the Bitbucket server, Atlasian (re-)introduced the webhooks. I tried to configure a webhook to notify our Jenkins 2.83 instance but the request was refused with an "Invalid crumb" message.

Please advise how to connect the new Bitbucket server webhooks to a Jenkins 2.x instance.

Please note that the invoked Jenkins job is of type Pipeline, which executes a parameterized script from an SCM.

Here are the details of the HTTP request and response:

Request details

Event type:

Test connection event

URL endpoint:

https://jenkinshost/view/all/job/playground/job/test_pipeline/buildWithParameters

Headers

X-Request-Id: b346ae6c-f455-43f0-92c4-d5e74f922bfc
X-Event-Key: diagnostics:ping

Body

No headers

-------------------------------------------------------------------------

Response details

HTTP status:

403

Headers

Cache-Control: must-revalidate,no-cache,no-store
Server: Jetty(9.4.z-SNAPSHOT)
X-Content-Type-Options: nosniff
Content-Length: 460
Date: Wed, 11 Oct 2017 05:27:33 GMT
Via: 1.1 localhost (Apache-HttpClient/4.4.1 (cache))
Content-Type: text/html; charset=ISO-8859-1

Body

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /view/all/job/playground/job/test_pipeline/buildWithParameters. Reason:
<pre>    No valid crumb was included in the request</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>

</body>
</html>

 

3 answers

You can use Generic Webhook Trigger Plugin. It does not require the crumb.

I have the same problem....

Our solution was to install "Pull request notifications" Bitbucket plugin:

It provides a good (for us) set of filters whether to trigger Jenkins for a build.

There is (at least) one main difference with the proposal of @Tomas Bjerre:  "Pull request notifications" Bitbucket plugin filters (sends or not) the requests at the Bitbucket side, while the "Generic Webhook Trigger" Jenkins plugin decides only on Jenkins side if to fulfill a received build request.

The approach to select depends only on your needs and possibilities :-)

This one allows you to insert the crumble and the documentation is a bit more accurate... But I am looking for a simple solution for:

1. Bitbucket: On pull request, calls Jenkins job with parameters and the two URLs: repository and forked repository,

2. Jenkins job merge and build and report result to the pull request on Bitbucket

3. Integrator can sip coffee instead of working hard... (:+)

But somehow, everything works apart of the "merge" between the two repository....

I am thirsty for advices

Thanks

Michele

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

21,857 views 26 11
Join discussion

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