How to Point BitBucket Webhook to Jenkins on Localhost

If you want to host your Jenkins locally on your computer for testing, but are interested in leveraging BitBucket’s webhooks to point to your localhost, then you need to expose your computer to the outside world.  There are several ways to do this, but the easiest I have found is to use a tool called ngrok. If you do not have it installed already and are using a Mac, I would suggest that you install it with Homebrew. This post was inspired by some instructions found on  GitHub actually, as opposed to BitBucket.

[code language=”bash”]
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew cask install ngrok
[/code]

You are ready to run ngrok now to expose your localhost to the outside world now. In this situation, I am demonstrating an example of exposing my local Tomcat; however, one word of caution is that you may not want to expose the default 8080 port. Reasons for doing this including a poor mans security to limiting the inbound traffic you expose yourself to by doing this. In order to change your default port for Tomcat, follow the instructions here. An even better option would be to expose a secure link on https.

So, presuming you have installed ngrok and you have changed your default port to something non-standard, then you are ready to run the tool to expose your machine to the outside world:

[code language=”bash”]
$ ngrok http 8282
[/code]

Once you run this command, you will see the program run in the foreground (ideally you would want to run this in the background and/or as a service on reboot). In order to test that you have set things up successfully, we can test by simply going to one of the two provided URLs in a browser and in my case it would take you to the Apache Tomcat landing page; however, we really want to test that we can get a webhook to work. So, in order to do this, we could use BitBucket to trigger a webhook to a Jenkins instance deployed to my local Tomcat whenever I push a code change to BitBucket. Here is the configuration:

Jenkins BitBucket webhook

Jenkins BitBucket webhook

Now, we just need to make a code change and push it for testing. We can see both from ngrok and BitBucket that things worked by witnessing the HTTP 200 OKs.

ngrok running and it has successfully received two push requests from the webhook in BitBucket

ngrok running and it has successfully received two push requests from the webhook in BitBucket

Jenkins BitBucket Webhook Successful 200 OK requests log

Jenkins BitBucket Webhook Successful 200 OK requests log

By default, ngrok will only give you a session that last few a few hours at a time. Your options are to periodically restart your tunnel to expose your IP to the outside world, which also means needing to update your webook with the newest URL, or to sign up and register an authorization token: https://ngrok.com/upgrade. Even so, if you restart your command again (ie, reboot your machine or accidentally close the terminal that you used to launched the program), then you will still get a new URL.. As you may have guessed, the want you to pay them to get a static address.

210 Comments:

  1. The blend of informative and entertaining content is perfect. I enjoyed every word.

  2. The post resonated with me on many levels. Thank you for writing it!

  3. This post is packed with insights I hadn’t considered before. Thanks for broadening my horizons.

  4. The perspective is incredibly valuable to me. Thanks for opening my eyes to new ideas.

  5. Appreciate the balance and fairness, like a judge, but without the gavel.

  6. This is a brilliant piece of writing. You’ve nailed it perfectly!

  7. The insights are like keys, unlocking new perspectives and ideas I hadn’t considered.

  8. The article was a joy to read, and The enthusiasm is as infectious as The charm.

  9. Delightful read. The passion is visible, or at least, very well faked.

  10. Impressed by The nuanced clarity. It’s like you’re explaining quantum physics to a toddler, and they get it.

  11. The writing style had me at hello. Engaged from start to finish, just like a perfect first date.

  12. Brilliant writing! You’ve perfectly captured the essence of the topic.

  13. The clarity of The writing is like a perfectly tuned instrument, making hard to understand melodies seem effortless.

  14. The unique perspective is as intriguing as a mystery novel. Can’t wait to read the next chapter.

  15. I appreciate the balance and fairness in The writing, like a perfect partner who always keeps things interesting. Great job!

  16. You’ve done a fantastic job of breaking down this topic. Thanks for the clarity!

  17. Brilliant writing! You’ve perfectly captured the essence of the topic.

  18. The depth you bring to The topics is like diving into a deep pool, refreshing and invigorating.

  19. Making hard to understand topics accessible is a gift, and you have it. Thanks for sharing it with us.

  20. The consistency and high quality of The content are something I really appreciate. Thank you for The dedication.

  21. You tackle topics with such finesse, it’s like watching a skilled chef at work. Serving up knowledge with flair!

  22. The posts are like a cozy nook, inviting and comfortable, where I can immerse myself in thoughts.

  23. The blend of informative and entertaining content is perfect. I enjoyed every word.

  24. I’m bookmarking this for future reference. The advice is spot on!

  25. The approach to topics is like a master painter’s to a canvas, with each stroke adding depth and perspective.

  26. This post is packed with insights, each one a gentle nudge to my intellect and curiosity.

  27. Bookmarking this for future reference, but also because The advice is as invaluable as The attention.

  28. Stumbling upon The article was a highlight of my day. It was just what I needed to read.

  29. The work is both informative and thought-provoking. I’m really impressed by the high quality of The content.

  30. The insights add so much value, like an unexpected compliment that brightens one’s day. Thanks for sharing.

  31. The unique viewpoints in The writing never fail to impress me. Insightful as always!

  32. Thank you for adding value to the conversation with The insights.

  33. This post has been incredibly helpful, like a guiding hand in a crowded room. The guidance is much appreciated.

  34. Making hard to understand topics accessible is a gift, and you have it. Thanks for sharing it with us.

  35. The hard work you put into this post is as admirable as The commitment to high quality. It’s very attractive.

  36. A constant source of inspiration and knowledge, like a muse but less mythical.

  37. Most comprehensive article on this topic. I guess internet rabbit holes do pay off.

  38. A constant source of inspiration and knowledge, like a muse but less mythical.

  39. This is the most thorough piece I’ve read on the topic. The dedication to research is admirable.

  40. Reading The work is like watching the sunrise, a daily reminder of beauty and new beginnings.

  41. A beacon of knowledge, or so I thought until I realized it’s just The shining confidence.

  42. This is one of the most comprehensive articles I’ve read on this topic. Kudos!

  43. You’ve articulated The points with such finesse. Truly a pleasure to read.

  44. The approach to topics is like a master painter’s to a canvas, with each stroke adding depth and perspective.

  45. The insights added a lot of value, in a way only Google Scholar dreams of. Thanks for the enlightenment.

  46. I learned a lot, and now I’m curious about what else you could teach me. The intelligence is as captivating as The prose.

  47. Reading the article on the state of the country was a joy. The enthusiasm for the topic is really motivating.

  48. You weave words with the skill of a master tailor, crafting pieces that fit the mind perfectly.

  49. The piece was both informative and thought-provoking, like a deep conversation that lingers into the night.

  50. The Writing is a treasure trove of knowledge, like finding an untouched library book. A rare gem!

Leave a Reply

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