None bitbucket sample works
I run samples with my bitbucket account/password and found no samples in bitbucket really works
Most samples return 'generator' object has no attribute 'json'
or Not supported in Bitbucket Cloud
BTW, it said this is a well documented API, but
- No document about the generator of BitbucketBase
- https://atlassian-python-api.readthedocs.io/ content is outdated and give no clue about how to parse result, if any?
Is there any update on this?
The below example returns a generator object and its really hard trying to figure out how to process it: https://github.com/atlassian-api/atlassian-python-api/blob/master/examples/bitbucket/bitbucket_get_project_list.py
@djgoku Can you please help out.
I run samples with my bitbucket account/password and found no samples in bitbucket really works
Can you share some code? What are you wanting to access?
Here is an example that I am using:
from atlassian.bitbucket import Cloud
bitbucket = Cloud(
username=os.getenv('BITBUCKET_USERNAME'),
password=os.getenv('BITBUCKET_PASSWORD')) # This needs to be an app password (with correct permissions) if using bitbucket MFA.
workspace = bitbucket.workspaces.get('workspace-name')
for repository in workspace.repositories.each():
print(repository.name)
I would check out this for more Bitbucket Cloud code : https://atlassian-python-api.readthedocs.io/bitbucket.html#bitbucket-cloud
Is there any update on this?
The below example returns a generator object and its really hard trying to figure out how to process it: https://github.com/atlassian-api/atlassian-python-api/blob/master/examples/bitbucket/bitbucket_get_project_list.py
I can't really help you with Bitbucket Server. Here is how you can get project lists with Bitbucket Cloud:
from atlassian.bitbucket import Cloud
bitbucket = Cloud(
username=os.getenv('BITBUCKET_USERNAME'),
password=os.getenv('BITBUCKET_PASSWORD')) # This needs to be an app password (with correct permissions) if using bitbucket MFA.
workspace = bitbucket.workspaces.get('workspace-name')
for project in workspace.projects.each():
print(project.name)
@djgoku The example you shared is for Bitbucket Cloud but I am looking for examples for the Bitbucket server. I am trying to get a list of all open PRs for all repositories within a project.
@djgoku The example you shared is for Bitbucket Cloud but I am looking for examples for the Bitbucket server. I am trying to get a list of all open PRs for all repositories within a project.
I think this will get you close:
from atlassian import Bitbucket
bitbucket = Bitbucket(url="http://localhost:7990", username="admin", password="admin")
project_key = "PROJ"
repository_slug = "repository-slug"
for pull_request in bitbucket.get_pull_requests(project_key, repository_slug):
print(f"pull request title {pull_request.title} description {pull_request.description}")
@djgoku Thank you for the above info. In the above example, how can I use bitbucket.repo_list(project_key) or repo_all_list("project_key") to get a list of all repos, get the repo_slug from them and pass it to get pull_requests?
The issue with repo_list or repo_all_list is that they return a generator object and I am not sure what the best way to iterate over it. Can you please provide an example like the above to get a list of all repos, get the repository slug for all given just the project key?
Hi, a generator object is Python related. If used on the right side of a for loop it yields every entry. This is used for reducing load on the server since the Snext page is retrieved when needed. With the list function you can create a list out of a generator.
Yup, I figure out the issue. I was setting advanced_mode to true while creating the bitbucket session:
bitbucket = Bitbucket(
url='http://abc.com',
username="******",
password="*****",
advanced_mode=True)
Thank you for helping out @djgoku and @Spacetown.