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

Want to get the all commits lists per user in bitbucket.

Yusuf Khan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 5, 2023

Hi,

I am trying to get the list of commits and line of codes changed by per user in bitbucket cloud.
I tried using api's
step followed for API :
 - Generated Oauth token using endpoint

- Used this access token to get repositories using endpoint 
https://api.bitbucket.org/2.0/repositories?access_token={access_token}&role=member"

It worked to list repositories but when I used the endpoint -
https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/commits

This is also not working.

Then I followed this document : https://atlassian-python-api.readthedocs.io/index.html

In this the bitbucket cloud part is not much helping.
How we can use this localhost parts in bitbucket cloud which will also be helpful.
how we can create a bitbucket cloud client so we can use below method?

# Get pull request commits
bitbucket.get_pull_requests_commits(project, repository, pull_request_id)

 

Please help me here how we can achive this?

Is there any bitbucket cloud app(marketplace) which can also help me here.

 

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2023

Hello @Yusuf Khan and welcome to the community!

In order to authenticate the API call using an access token, you will need to provide the access token in a Header named Authorization, where the value should be the word Bearer followed by the access token itself.

Below is an example of a request to List all the commits in a repository, including the access token in the request : 

curl --request GET --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/commits' --header 'Authorization: Bearer <access_token>' --header 'Accept: application/json'

To get the access token used in the authentication, you will first need to call the below endpoint, providing the Key (clientId) and Secret (clientSecret) of the bitbucket OAuth consumer : 

curl -X POST -u "ClientID:ClientSecret" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials

The token is only valid for 2 hours, so after it expires you will need to get a new access token by calling the API endpoint above again.

As for your question about apps that can help build those reports, you can check the available Reports apps using the following link : 

Thank you, @Yusuf Khan !

Patrik S

Yusuf Khan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 7, 2023

Hi @Patrik S ,

 

Thanks for your help about api.

The reporting apps you suggested. In those, is there any way to export that data in CSV, particularly commits data.
I have tried to use awesome graphs app but bitbucket cloud version of this app does not have any option to export data.

Please help me.

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 11, 2023

Hello @Yusuf Khan ,

Those apps are developed and maintained by third parties, so I would suggest reaching out to the app's vendor by opening the app on the marketplace and clicking on the Support option.

Thank you, @Yusuf Khan !

Patrik S

Suggest an answer

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

Atlassian Community Events