youngmon/atlassian-qna huggingface dataset:
How to get commit code that belongs to a jira issue by Development Rest API
Asked by Bashayer Alsalman:

I want to get the difference between the code when pulling the commits via development API,

I got the list of issues and then the list of commits that are related to the Jira Issue, but I could not get the exact source code.


Answers:
author: Patrik S
body: Hello [@Bashayer Alsalman](/t5/user/viewprofilepage/user-id/5224911) and welcome to the Community!

As you mentioned you were already able to get the list of issues and their related commits, if you want to compare the diff between commits, the [Compare two commits](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-diff-spec-get) endpoint can be used:

```
https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/diff/<spec>
```

Where the spec parameter can be a commit id, a branch name, or a tag.

Following is an example request to get the diff between two commits :

```
curl -X GET -u USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/diff/aa35f95..259de05
```

This should return the diff between the source commit and the merge base of the source commit and the destination commit.

However, if you want to get the content of files/directories within the repository, then the [Get file of directory contents endpoint](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get) might be useful. Below is an example request listing all the files and directories up to **max_depth** in commit **259de05**

```
https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/src/259de05/?max_depth=10
```

The max_depth will control the number of nested directories that will be returned. The object returned from this API will just contain the list of the files/directories. If you would like to get the actual raw content of a file, you will need to follow the **links.self.href** of each file entry returned in the JSON.

Hope that helps! Let me know in case you have any questions.

Thank you, [@Bashayer Alsalman](/t5/user/viewprofilepage/user-id/5224911) !  
Patrik S


Tags: bitbucket-development

jira

jira-development

rest-api
SONAR Cloud Integration
Asked by Parakh Maheshwari:

While trying to integrate SonarCloud and Bitbucket, the pipeline is failing because of non existing toolchains.

Please make sure you define the required toolchains in your \~/.m2/toolchains.xml file.

Is there a way to add toolchains via pipelines and cache it as well.


Answers:
author: Patrik S
body: Hello [@Parakh Maheshwari](/t5/user/viewprofilepage/user-id/5224901) and welcome to the Community!

The error you reported seems to actually be a Maven-related error (see [Maven - Guide on using Toolchain](https://maven.apache.org/guides/mini/guide-using-toolchains.html) ). When defining the usage of the maven-toolchains-plugin in your pom.xml file, maven will by default look for the toolchains.xml file under the folder

```
 ${home}/.m2/
```

If the file toolchains.xml is not that path, maven will fail with the error message you reported.

Since pipelines clone your repository files into the build container during the start of your build, one option would be for you to push the **toolchains.xml** to a folder in your repository, so this file will be cloned along with the repository during the build start. Then during the build time, you can move/copy the **toolchains.xml** to the ${home}/.m2/ folder

For example, if you have pushed the **toolchains.xml**file to the root of your repository, you would need to add the following command in your pipeline's script to copy this file to directory ${home}/.m2/ :  

```
- step:
    script:
      - mkdir -p ${home}/.m2 && cp toolchains.xml ${home}/.m2/
      - <rest of your commands>
```

This would create the folder ${home}/.m2 and copy the toolchains.xml (that was added to the root of your repository) into that folder.

Hope that helps! Let me know in case you have any questions.

Thank you, [@Parakh Maheshwari](/t5/user/viewprofilepage/user-id/5224901) !

Patrik S

comments: author: Parakh Maheshwari
body: [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) : Thank you so much for the steps.

I still have one question, what should we define as jdk path in toolchains?

\<configuration\>  
\<jdkHome\>/opt/atlassian/pipelines/agent/build/.jdk/jdk11\</jdkHome\>  
\</configuration\>

Is throwing me "**Non-existing JDK home configuration at /opt/atlassian/pipelines/agent/build/.jdk/jdk11**"

An update to toolchains is required or is there a path with respect to bitbucket that we can define for the pipeline to work ?


author: Patrik S
body: Hello [@Parakh Maheshwari](/t5/user/viewprofilepage/user-id/5224901) ,

This very much depends on the docker image you are using on your build step, as it might have the JDK installed in a different path.

Could you share what is the image you are using in your pipeline and what is the JDK version you would like to point to in your toolchains.xml file?


author: Parakh Maheshwari
body: Thanks [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) We were able to proceed with the suggestion provided.

Thanks a ton for taking this up.


Tags: bitbucket-cloud

cloud

sonarcloud
How to add a webhook to my bitbucket repository?
Asked by Shakshi Gularia:

Cannot see the option anywhere to configure bitbucket repository


Answers:
author: Ankit Anway
body: Hi Shakshi,

Welcome to the community !!

You can create a webhook through Bitbucket Cloud or with the API. Use the following steps to create a webhook on a repository in Bitbucket.

1. From Bitbucket, open the repository where you want to add the webhook.

2. Click **Repository settings** on the left sidebar.

3. On the **Settings** page, select **Webhooks** on the left sidebar.

4. Click the **Add webhook** button to create a webhook for the repository.

5. On the **Add new webhook** page, enter a **Title** with a short description.

6. Enter the **URL** to the application or server.

7. (Optional) If you don't want the webhook to be active after you save, remove the checkmark from **Active**.

8. (Optional) If you're using a self-signed certificate and want to disable certificate verification, select **Skip certificate verification**.

   **Note:**We recommend that you don't disable certificate verification because self-signed certificates are inherently not secure. Read the next section for more information about why you would or wouldn't use self-signed certificates.
9. If necessary, update the **Triggers** field.  
   By default, the trigger for the webhook is a repository push, as demonstrated by the **Repository push** field. If you want additional or different actions to trigger the webhook, click **Choose from a full list of triggers**. You will see a list of all the event types that can trigger the webhook.

10. After you entered all the necessary information for your webhook, click **Save**.

**NOTE :**

* The administrators of a repository are the only users who can create a webhook on that repository.
* You can create up to 50 **webhooks**per repository.

Please feel free to reach out if you have any questions.  
Kind regards,  
Ankit

comments: author: Shakshi Gularia
body: Describe a way to enable people to get notified about changes in the respository like push, pull, commit. How to enable this in bitbucket?


author: Ankit Anway
body: Hi Shakshi,

Greetings for the day !!

Bitbucket Cloud sends you email notifications about activity that takes place in your account or things you watch.

You can refer to below links.

[Manage Email Notification](https://support.atlassian.com/bitbucket-cloud/docs/manage-email-notifications-for-watched-objects/)

[Repository-Notifications](https://confluence.atlassian.com/bitbucketserver/repository-notifications-949754838.html)

Please feel free to reach out if you have any questions.  
Kind regards,  
Ankit


Tags: bitbucket-cloud

cloud
Where is the "App passwords" now?
Asked by Chris:

Where is the "App passwords" now? It is not in the place described in <https://support.atlassian.com/bitbucket-cloud/docs/create-an-app-password/>


Answers:
author: Roland Traier-Kiss _Midori_
body: Hi [@Chris](/t5/user/viewprofilepage/user-id/5033432),  

Click the cogwheel icon (top bar), then "Personal Bitbucket settings", and you'll see the "App passwords" option on the left sidebar.


Tags: bitbucket-cloud

cloud
Need to fetch lines of code of a bitbucket repository using any available API and python
Asked by kompal.sithta:

Hi All,

We are trying to fetch the lines of code from a bitbucket repository using python and any API available.

Till now we have tried to seek help from the following blog post - <https://stiltsoft.com/blog/how-to-count-lines-of-code-in-bitbucket-to-decide-what-sonarqube-license-you-need/> but we are facing errors while establishing the connection.

Is there any method, api, documentation from where we can fetch this data?


Answers:
author: Patrik S
body: Hello [@kompal.sithta](/t5/user/viewprofilepage/user-id/5079083) and thank you for reaching out to the community!

I'm afraid that currently Bitbucket Cloud does not have a built-in feature to track code statistics, like the number of lines of code in a workspace or repository, so we don't currently have an API for that particular operation. We do have an open feature request to implement this functionality, which you can access with the link below :

* <https://jira.atlassian.com/browse/BCLOUD-20226>

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with [this policy](https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html) in mind.

While this feature is not available, you have the option to clone the repository locally and use the following git command to get the total number of lines per repository file :

```
git ls-files | xargs wc -l      50 .gitignore      44 README.md       1 fileA.txt       1 fileB.txt       2 fileD.txt      98 total
```

Alternatively, you can also check out for available code reviews add-ons in Bitbucket's Marketplace :

* [https://marketplace.atlassian.com/search?category=Code%20review\&product=bitbucket](https://marketplace.atlassian.com/search?category=Code%20review&product=bitbucket)

Thank you, [@kompal.sithta](/t5/user/viewprofilepage/user-id/5079083) !  
Patrik S


author: Uladzislava Kastsitsyna _Stiltsoft_
body: Hi [@kompal.sithta](/t5/user/viewprofilepage/user-id/5079083)

I am Vlada from the [Awesome Graphs for Bitbucket](https://link.stiltsoft.com/yddmms) team and I wanted to share that the article you are reading refers to Bitbucket Data Center instances. You are using Cloud, right?

Could you possibly describe your use case in more detail? I would love to record your request in our backlog for Cloud features.

Best regards,  
Uladzislava


Tags: atl-gruland

bitbucket-cloud

cloud
Get repository wide audit logs
Asked by d.acharya:

Hi,

I was looking to get repository wide audit logs, which provides details who has access to the repository and who are allowed to push to master/develop branches of the repository. Is that possible to get this kind of audit logs based on timestamp?

Let me know.

Thanks,

Acharya


Answers:
author: Patrik S
body: Hello [@d.acharya](/t5/user/viewprofilepage/user-id/1637487) and thank you for reaching out to Atlassian Community!

If you would like to check the users/groups that currently have access to a repository and their level of access, this can be achieved by navigating to **Repository Settings \> Repository permissions**. There you will see all the users and groups that have direct or inherited permissions to the repository in question.

As for the users that have permission to push to a given branch, this can be checked in **Repository Settings \> Branch restrictions** . [Branch restrictions](https://support.atlassian.com/bitbucket-cloud/docs/use-branch-permissions/) are used to control the permissions at the branch level, for example, which users have access to push to a specific branch or branch pattern. If a given branch does not have branch restrictions applied to it, this means any user that has write access to the repository can push to that branch.

However, if you are looking for the history of events in your workspace, you can access the workspace audit logs by navigating to Workspace Settings \> Audit logs. Unfortunately, clone/pushes to repositories are not currently included in the Audit logs, and we have the following feature request to add those events in the logs as well :

* <https://jira.atlassian.com/browse/BCLOUD-9622>

We recommend adding your **vote** there to demonstrate your interest, and also mark yourself as a **watcher**to be notified whenever there's any update on the implementation of that feature.

Thank you, [@d.acharya](/t5/user/viewprofilepage/user-id/1637487) !

Patrik S

comments: author: d.acharya
body: Thanks for the response.


Tags: bitbucket-cloud

cloud
git gc Request for remote
Asked by Nafis Abdullah Khan:

Hello,

I need a git gc performed on a remote repository please.

Repository: \<workspace-id\>/\<repo\>


Answers:
author: Theodora Boudale
body: Hi [@Nafis Abdullah Khan](/t5/user/viewprofilepage/user-id/5224524) and welcome to the community!

I ran a git gc for your repository and its size has been reduced. Could you please check if it looks ok now on your end?

Just a heads up, I removed the repo details to protect your privacy. In case you ever need to create a similar request in the future, you could provide just a few letters from the workspace-id and repo name, and we can identify the repo from the ones you have access to.

Kind regards,  
Theodora

comments: author: Nafis Abdullah Khan
body: It worked! Thanks a lot!


author: Theodora Boudale
body: That's good to hear, you are very welcome!

Please feel free to reach out if you ever need anything else!


Tags: bitbucket-cloud

cloud

gc-request
Update Bitbucket Cloud SSH Host Keys (replace current RSA and remove DSA host key) and TortoiseGit
Asked by yuri-s:

I try the following command:  
$ ssh git@bitbucket.org host_key_info  

and receive:  
git@bitbucket.org: Permission denied (publickey).  

instead of the  
You are using host key with fingerprint: ssh-ed25519 SHA256:ybgmFkzwOSotHTHLJgHO0QN8L0xErw6vd0VhFA9m3SM See <https://bitbucket.org/blog/ssh-host-key-changes> for more details.  

acording to this explanations:  
[ACTION REQUIRED: Update your Bitbucket Cloud SSH Host Keys - Bitbucket](https://bitbucket.org/blog/ssh-host-key-changes)  

Thank you  

<br />


Answers:
author: Theodora Boudale
body: Hi [@yuri-s](/t5/user/viewprofilepage/user-id/5224418) and welcome to the community!  
The instructions we have on the blog are for OpenSSH (or compatible) clients. You mentioned TortoiseGit in the title of your post, and I see that TortoiseGit uses TortoiseGitPlink by default as SSH client:

* <https://tortoisegit.org/support/faq/#sshconfigignored>

You first need to figure out which SSH client is configured in TortoiseGit. Is it TortoiseGitPlink, PuTTY, OpenSSH, or a different one?  
In case you are using PuTTY: PuTTY in Windows does not use the \~/.ssh/known_hosts file, but stores the known hosts in the Windows Registry. Please look at the following FAQ, the questions related to PuTTY and SourceTree for Windows for instructions on how to update the known hosts on PuTTY:

* <https://confluence.atlassian.com/bbkb/bitbucket-cloud-ssh-host-key-rotation-faq-1235851234.html>

In case you are using TortoiseGitPlink, you should consult its documentation on how to update its configuration.  
If you are using OpenSSH, you can create a file named **config** in your \~/.ssh folder and add the following lines (if the file exists, just add the following content)

```
Host bitbucket.org
? ? ? ? AddKeysToAgent yes
? ? ? ? IdentityFile ~/.ssh/id_rsa
```

where **\~/.ssh/id_rsa** replace with the path and name of the private SSH key, whose public key you have uploaded to Bitbucket. Afterwards, try the command **ssh git@bitbucket.org host_key_info** one more time. The error you receive means that your client cannot authenticate to Bitbucket, possibly because your key may not be offered, and a config may help in this case.  
Please feel free to reach out if you have any questions.  
Kind regards,  
Theodora


author: Aron Gombas _Midori_
body: What is the question?

In the article you linked there is an explanation why the key change is necessary, and Atlassian even provide the steps to make it happen. I followed their guide and it worked perfectly (on Linux).


Tags: bitbucket-cloud

cloud
I need to integrate Bitbucket with Jenkins windows machine
Asked by Yugender Janam:

I have integrated with Git and now I need to Integrate Jenkins with Bitbucket but somehow I am getting the Authentication issues so can you please help me in establishing the connection between Jenkins and Bitbucket.


Answers:
author: Yugender Janam
body: I could able to resolve by enabling the SSH key to establish the connection between Jenkins and Bitbucket.

Thanks a lot for your inputs and support.


author: jennifer.dempsey_Appfire
body: Hi [@Yugender Janam](/t5/user/viewprofilepage/user-id/5224661)

Appfire's [Webhook to Jenkins for Bitbucket](https://marketplace.atlassian.com/apps/1211284/webhook-to-jenkins-for-bitbucket?tab=overview&hosting=datacenter) can help you achieve your goal. It will enable you to trigger a build in Jenkins when a Pull Request is merged.

You can reach out to our awesome [support](https://appfire.atlassian.net/servicedesk/customer/portal/11)team to ask any questions you might have about this powerful integration app.

You can also email me at [Jennifer.dempsey@appfire.com](mailto:Jennifer.dempsey@appfire.com) and I can put in contact with our PM to further discuss your needs and schedule a demo. We'd be happy to help you any time!

Warmly,

Jennifer Dempsey, Product Marketing Manager, Appfire

comments: author: Yugender Janam
body: Hi [@jennifer.dempsey_Appfire](/t5/user/viewprofilepage/user-id/5093038) Thanks a lot for your inputs my issue got resolved.


author: jennifer.dempsey_Appfire
body: Glad to hear it, [@Yugender Janam](/t5/user/viewprofilepage/user-id/5224661)


author: Patrik S
body: Hello [@Yugender Janam](/t5/user/viewprofilepage/user-id/5224661) and welcome to the Community!

You can use the following Jenkins plugin, developed by a third party, in order to integrate your bitbucket cloud repository with Jenkins :

* <https://plugins.jenkins.io/bitbucket/>

Essentially, this plugin relies on bitbucket webhooks to receive the events that happen in your bitbucket repository, such as a new push, to then trigger an event in your Jenkins instance.

You are also welcome to take a look at the following article with step-by-step instructions on how to set up this integration :

* <https://medium.com/ampersand-academy/integrate-bitbucket-jenkins-c6e51103d0fe>

If after following those instructions you are still facing authentication issues, we kindly ask you to share a screenshot/log that contains the error message so we can investigate further.

Thank you, [@Yugender Janam](/t5/user/viewprofilepage/user-id/5224661) !

Patrik S

comments: author: Yugender Janam
body: Hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) thanks a lot for your time and Inputs I got the solution and I am able to proceed further.


Tags: bitbucket-cloud

cloud
Will the new SSH keys affect sourcetree?
Asked by Ben Sprott:

I saw the new key alert for June, the one that said new keys will be forced into the system in June. I use SourceTree for simple development. Will I have to change my keys or do anything else? If so, can we get a link to the steps involved?


Answers:
author: Theodora Boudale
body: Hi Ben,

If your repositories in SourceTree are using SSH, then the change affects SourceTree as well.

You can check the following FAQs page (look for the questions about SourceTree, there is a question for SourceTree for Mac and another one for SourceTree for Windows):

* <https://confluence.atlassian.com/bbkb/bitbucket-cloud-ssh-host-key-rotation-faq-1235851234.html>

Please keep in mind that the instructions for SourceTree for Windows are applicable only if you have configured SourceTree to use PuTTY as an SSH client. If you have configured SourceTree to use OpenSSH instead, then you can follow the instructions on the blog in the section WHAT YOU NEED TO DO.

Please feel free to reach out if you have any questions.

Kind regards,  
Theodora


author: Ben Sprott
body: This is what I am talking about here:

<https://bitbucket.org/blog/ssh-host-key-changes>


Tags: bitbucket-cloud

cloud
bitbucket api /users endpoint doesn't seem to work, is this expected?
Asked by coleman.jackson:

Hi all.  

I am trying to get the uuid of users on bitbucket cloud from passing in a username via the users endpoint in the bitbucket api v2.0 (documented [here](https://developer.atlassian.com/cloud/bitbucket/rest/intro/#user-object-and-uuid)). However, the endpoint is appearing to error out, both when I try a real user and when I try the tutorial user.  

Command I run:

```
`curl https://api.bitbucket.org/2.0/users/tutorials`

```

and the response:  
{"type": "error", "error": {"message": "tutorials"}}

<br />

It does this with any username I pass in.

is this normal? If not, what do I need to do to fix the command?


Answers:
author: Patrik S
body: Hello [@coleman.jackson](/t5/user/viewprofilepage/user-id/2895301) and thank you for reaching out to the community!

As part of user privacy improvements, back in 2019 the Bitbucket Cloud API has have [Removed usernames from user-referencing APIs](https://developer.atlassian.com/cloud/bitbucket/bitbucket-api-changes-gdpr/#removal-of-usernames-from-user-referencing-apis) . This means that the username is no longer supported in the [/users endpoint](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-users-selected-user-get), and you will need to identify the account with the **uuid** or **account_id** (Atlassian account id) :

```
`/2.0/users/{UUID}`

`instead of `

`/2.0/users/username`
```

With that in mind, if you would like to fetch the UUID of the user used to authenticate the API request, the [Get current user endpoint](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-user-get) can be used :

```
curl -X GET -u USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/user
```

The above endpoint only ever returns the authenticated user's own user object, not that of other users.

However, if you would like to get the UUID of the members of a workspace you have access, the [List users in a workspace endpoint](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-workspaces/#api-workspaces-workspace-members-get) might be useful :

```
https://api.bitbucket.org/2.0/workspaces/<workspace>/members
```

This should return all the users that are part of the provided workspace, along with their **uuid** and **account_id**.

Hope that helps! Let me know if you have any questions.

Thank you, [@coleman.jackson](/t5/user/viewprofilepage/user-id/2895301) !

Patrik S


Tags: bitbucket-cloud

cloud
Cant login into bitbucket account
Asked by Sami Nunes:

i am getting an error when i try to login to bitbucket account

![error.jpg](/t5/image/serverpage/image-id/258520iD4EA7C05F153255A/image-size/large?v=v2&px=999 "error.jpg")


Answers:
author: Ben
body: Hi Sami,

Your account was de-activated as it was not logged into for a long period of time - I've just re-activated your account so you should be able to login now without issue.

Please let me know how this goes :)

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: Sami Nunes
body: It worked, thanks!


Tags: bitbucket-cloud

cloud