Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

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

How to list all repositories having secrets using bitbucket Cloud API

mhumair7 July 29, 2024

 

How to list all repositories having secrets using bitbucket Cloud API

1 answer

1 accepted

2 votes
Answer accepted
Stefano Galati
Contributor
July 29, 2024

Hi @mhumair7

You can’t directly use the Bitbucket Cloud API to list all repositories with secrets. The API doesn’t provide a specific endpoint for that. But, you can list all repositories and then check each one for secrets in the pipeline environment variables. Here’s the API to list repositories:

https://api.bitbucket.org/2.0/repositories/{username}

Want me to whip up a Python script (or any other language) to automate the process of checking each repository for secrets? Let me know, and I’ll get on it!

mhumair7 July 29, 2024

Hi @Stefano Galati Appreciate the quick help. I'll get back to you on that if needed. 

Like Stefano Galati likes this
mhumair7 July 29, 2024

Just a side question though @Stefano Galati . Is there a way to export meta data like pull requests and stuff in a given workspace or project from Bitbucket Cloud ?

Stefano Galati
Contributor
July 29, 2024

Sure thing, @mhumair7 ! You can export metadata like pull requests and other details from a given workspace or project in Bitbucket Cloud.

Here are the main steps:

Use the API to List Repositories with a get tonretrieve a list of all repositories in the workspace.

GET https://api.bitbucket.org/2.0/repositories/{workspace}

After that fetch Pull Requests for all repos

GET https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests

 Then export other metadata like commits, issues, etc., by using their respective API endpoints.

Like before if you need help with thé code let me know 😉

Like mhumair7 likes this
mhumair7 July 31, 2024

Hi @Stefano Galati . One last thing. I'm exporting pull requests but is there a cap to it ?
Because it seems all of the pull requests aren't exporting for a given repo.

Stefano Galati
Contributor
August 2, 2024

Hi @mhumair7 

I’m in holiday with not a good connection sorry for the late..

I will check asap and give you a response

mhumair7 August 16, 2024

Hi @Stefano Galati Can you guide me related to this module too ? 

https://atlassian-python-api.readthedocs.io/bitbucket.html#manage-repositories

I'm unable to find a method that can help me find users permissions on a given repo like the one that exists to get for groups :

repository.group_permissions.each():

https://atlassian-python-api.readthedocs.io/bitbucket.html#manage-repositories

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events