Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to capture pull request creation event in bitbucket using python script Edited

‘’’’
Need to know if there is any possible way to capture the event of pull request creation in bitbucket to write a custom script using this event.

Dont want PR to trigger any automatic build instead just need capture the pr creation event to write a custom python script to trigger certain activities through script run.

One option is to read/continuous poll the bit bucket PR creation page to identify the activity/event but it sounds to be a bad scripting standard and not a good practice.

Is there any git command to identify PR creation at feature branch and to merge into parent(say its DEV) and also git command to capture PR default reviewer names???

So that, these git commandS can be used in script To track if any PR is raised?

Verified many websites and read many articals and unfortunately no where found the possibility to capture the PR creation event in but bucket?

Great if anyone can post the possibility to capture the event to write our own custom logic with the PR event capture
‘’’’

1 answer

0 votes
Daniel Eads Atlassian Team Sep 16, 2020

Hello Jayadev, welcome to the Community!

Sounds like you're trying to trigger action in an external system (possibly a python script of your own making) when a pull request is created in Bitbucket, yes?

Fortunately there's a mechanism for triggering API calls on PR creation and many other events: webhooks

Without webhooks, if you want to detect when events occur in Bitbucket Cloud, you need to poll the API. However, polling the API is inconvenient, inefficient, and error-prone. Consider how SMS messages work on mobile phones. You don't have to check your messages every 5 minutes to see if you have a text because your phone sends you a notification. In the same way, webhooks work like the notification so that the API does not have to check for the same activity every minute.

In Bitbucket's repository settings, you create the webhook and its trigger events. You'll need to provide the URL of a service listening for events; this can be a bit tricky if you're considering a python script. There are a few routes you could go down:

  1. Use a python library that creates a listening server. With Javascript, this would be something like node.js. In python, you have options like socket from the standard library
  2. You could put your script into a serverless service like AWS Lambda that runs a small docker container and executes your script when it receives a trigger
  3. Depending on complexity, you could use a service like Zapier or IFTTT to receive the webhook from Bitbucket and trigger additional API calls in your destination applications.

More information about configuring webhooks and what triggers you can use are available in our documentation: Manage webhooks in Bitbucket 

I hope this helps and happy to clarify any points you're unsure about!

Cheers,
Daniel

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,926 views 0 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you