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.

230 Comments:

  1. The thought-provoking post has me looking forward to more. It’s like the intellectual equivalent of a second date.

  2. The elegance of The arguments is as captivating as a sunset. I could admire it all day.

  3. Reading The post was like going on a first date with my mind. Excited for the next rendezvous.

  4. The writing style is captivating! I was engaged from start to finish.

  5. This post was a breath of fresh air, like a surprise message that brightens The day. Thank you for the lift.

  6. Bookmarking this! The practical advice is something I’ll definitely be coming back to.

  7. Always excited to see The posts, like waiting for a message from a crush. Another excellent read!

  8. Every article you write is like a new adventure. I’m always excited to see where you’ll take me next.

  9. Thank you for shedding light on this subject. The perspective is refreshing!

  10. The commitment to high quality content really shows. I’m always excited to read The work.

  11. The balance and fairness in The writing make The posts a must-read for me. Great job!

  12. Testament to The expertise and hard work, or The ability to make me feel utterly unaccomplished.

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

  14. Each post is a window into The thoughts, and I must say, the view is stunning.

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

  16. The elegance of The prose is like a fine dance, each word stepping gracefully to the next.

  17. The article was a delightful read. It’s clear you’re passionate about what you do, and it shows.

  18. This was a great read—thought-provoking and informative. Thank you!

  19. Tackled this hard to understand issue with elegance. I didn’t know we were at a ballet.

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

  21. The words are like brush strokes on a canvas, painting ideas in my mind.

  22. Both informative and thought-provoking, as if my brain needed the extra workout.

  23. I appreciate the clarity and thoughtfulness you bring to this topic.

  24. I’m amazed by the depth and breadth of The knowledge. Thanks for sharing!

  25. The writing style is captivating. Finally, something that can keep my attention longer than a TikTok video.

  26. The argumentation was compelling and well-structured. I found myself nodding along as I read.

  27. The content is like a treasure chest; every post uncovers gems of wisdom. X marks the spot here.

  28. The post has been incredibly helpful. Thank you for the guidance!

  29. The take on hard to understand topics is like a smooth ride in a luxury car—comfortable, yet exhilarating.

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

  31. The insights dazzled me more than a candlelit dinner. Thanks for lighting up my intellect.

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

  33. Beautifully written and informative, making the rest of the internet look bad.

  34. The Writing has become a go-to resource for me. The effort you put into The posts is truly appreciated.

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

  36. The way you articulate The thoughts is as refreshing as the first sip of coffee in the morning.

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

  38. The information you’ve shared has been a revelation for me. Incredibly enlightening!

  39. I appreciate how you’ve explained things so clearly. It really helped me understand the topic better.

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

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

  42. The writing style is like a signature scent—distinct, memorable, and always pleasant.

  43. What a compelling read! The arguments were well-presented and convincing.

  44. Brilliant writing! You’ve captured the essence perfectly, much like a photographer captures a stunning landscape.

  45. The fresh insights were a breath of fresh air. Thank you for sharing The unique perspective.

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

  47. The words are like brush strokes on a canvas, painting ideas in my mind.

  48. The posts are like a secret garden of knowledge. I’m always excited to see what’s blooming.

  49. Reading The work is like catching up with an old friend; comfortable, enlightening, and always welcome.

  50. The Writing is a constant source of inspiration and knowledge, like a muse that never fails to inspire. Thank you for being my muse.

Leave a Reply

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