The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I would like to leverage Bitbucket api to get all remote branches(including merged and unmerged) in a repo which have not been updated for more than 180 days
Hey Sudheer! It definitely looks like what you're wanting to do is possible with just 2 API endpoints. You'd need to first iterate through the values (repos) provided from the /2.0/repositories/{workspace} endpoint to get a list of your repos and their respective repo-slugs. Once you've got that, you can pass the slug into the /2.0/repositories/{workspace}/{repo-slug}/refs/branches endpoint to get details on the last updated timestamp. Then you simply need to compare the timestamps with whatever date/time you wish.
At a super high level this would look like the following in python:
def repos():
# https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D
yield repo.get('name), repo.get('slug')
def branches(repo):
# https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/refs/branches
yield branch.get('name'), branch.get('target').get('date')
def main():
for repo_name, repo_slug in repos():
for branch_name, branch_date in branches(repo_slug):
if branch_date < desired_date: #less than == older than
print(f'{branch_name} on {repo_name} is older than desired.')
Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.