youngmon/atlassian-qna huggingface dataset:
Need a remote git gc, repository exceed 4GB size
Asked by Vlad Bujoreanu:

I did a hard reset to free up the space but the repo size remained the same, could you please help me?

Thank you.


Answers:
author: Caroline R
body: Hi, [@Vlad Bujoreanu](/t5/user/viewprofilepage/user-id/4888003), welcome to the community!

I ran the GC against your repository and managed to reduce its size.

I also would like to share with you that we have a feature request to allow users to mark repositories for git GC, as you can check here:

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

Please consider adding yourself as a watcher to receive the updates as we make progress with this. If you are not familiar with our Feature Request Policy, you can read more about it [here](https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html).

Feel free to share any additional questions or concerns regarding this case.

Kind regards,  
Caroline


Tags: bitbucket-cloud

cloud
Granting access for existing group to a private repository using REST API 2.0
Asked by Vinay Cheguri:

I am trying to add an existing group to a private bitbucket repository using REST API 2.0. I am not able to find any endpoint or curl command in the documentation.  

I came across a similar [question](https://community.atlassian.com/t5/Bitbucket-questions/Adding-users-groups-to-a-repository-using-REST-API-2-0/qaq-p/1545205) asked in 2020, and one of the answers says "At the moment there is no support for adding users/groups to a repo via API 2.0 in Bitbucket Cloud".  

Is it still the same or now the REST API 2.0 support for adding groups?  


Answers:
author: Mark C
body: Hi [@Vinay Cheguri](/t5/user/viewprofilepage/user-id/4887884)

Welcome to the community.

Unfortunately, there's still no API 2.0 endpoint for adding user groups to a repository.  
However, until we get a replacement for it, you can continue to use the API version 1 for adding user groups to a repository.

You can check the documentation on [this link](https://support.atlassian.com/bitbucket-cloud/docs/group-privileges-endpoint/#PUT-group-privileges-on-a-repository) (Under "PUT group privileges on a repository") for more information.

Here's the exact endpoint:

```
PUT https://api.bitbucket.org/1.0/group-privileges/{workspace_id}/{repo_slug}/{group_owner}/{group_slug} --data "{privilege}"
```

As an example, if your repository is: **some_workspace/some_repo**

And your user group name is: **some_group**

The API endpoint would look like these in a CURL command:

```
curl --request PUT --user bb_username:app_password https://api.bitbucket.org/1.0/group-privileges/some_workspace/some_repo/some_workspace/some_group --data read
```

![](https://getsupport.atlassian.com/images/icons/emoticons/information.png) Btw, please also make sure you're using an [App password](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/) (as your password credential) as we recently [deprecated the Atlassian account password](https://bitbucket.org/blog/deprecating-atlassian-account-password-for-git-and-bitbucket-api-activity).

Hope it helps and do let me know if you have further questions that I can help with.

Regards,  
Mark C

comments: author: Vinay Cheguri
body: Thanks, [@Mark C](/t5/user/viewprofilepage/user-id/1210823) for providing the replacement option


Tags: bitbucket-cloud

cloud

rest-api
Someone has already added that SSH key
Asked by douglas "dougbert" thompson:

I see that there are many requests with this issue

answers include create a ticket and then post the PUB there for look up

well where can one create a ticket, or would a support person create one for me

thanks


Answers:
author: Caroline R
body: Hi, Douglas, welcome to the community!

As we will need to know the public ssh key to further investigate this case, I have created an internal ticket for you using the email of your community account, so you don't have to share this information here.

You should have received an email with a link to the support ticket. Just in case you haven't received it, please feel free to let me know and I can post the ticket URL here. The ticket will be visible only to you and Atlassian staff, no one else can view its contents even if they have the URL.

Please feel free to let me know if you have any questions.

Kind regards,  
Caroline


author: Mikael Sandberg
body: Hi [@douglas "dougbert" thompson](/t5/user/viewprofilepage/user-id/4887493),

Welcome to Atlassian Community!

You can contract Atlassian Support using this link, <https://support.atlassian.com/contact/#/>. If it brings you back here, let me know and I can notify the support team that is here on the community.


Tags: bitbucket-cloud

cloud
Commits are confused becaus Jira projects with the same name from two instances point to Bitbucket
Asked by Andrea Hakim:

We recently migrated from one Jira instance to another. The issues in the new instance are showing commits from the old project - even after we rekeyed the project.

Here's the setup:

Jira instance 1, project BI - links to bitbucket

Jira instance 2, project BI - now also links to Bitbucket

If I create an issue in Jira2, BI-430 for example, the commit that was from JIRA2, BI-430 is showing.

We've tried to rename the BI project in Jira2, but it still references the oldkey in Bitbucket.

How do we remedy this?


Answers:
author: Luca Schioppa
body: Hi [@Andrea Hakim](/t5/user/viewprofilepage/user-id/624038) - were you ever able to solve this issue? running into exact same problem.


Tags: bitbucket-server

jira

server
How to configure proxy for bitbucket data center version 7.21?
Asked by Pedro Henrique de Brito Agnes:

We installed bitbucket data center with only one node so far on our server. This server has no access to the internet, so we need to configure a proxy for it so we can setup jira cloud integration.

The problem is that we are unable to do so, we tried to set the java opts listed at <https://confluence.atlassian.com/bitbucketserverkb/how-to-configure-an-outbound-http-and-https-proxy-for-bitbucket-server-779171680.html> on many different files, but all without success.

For reference, we are starting the application on a linux server by executing the file \<bitbucket installation directory\>/bin/start-bitbucket.sh


Answers:
author: Pedro Henrique de Brito Agnes
body: I managed to configure it in a way that does't seem ideal, but it works and I will leave a comment here to possibly help anyone that may face the same problem.

Basically, I set the params listed at the documentation on the file _start-webapp.sh in the variable JAVA_OPTS. The only problem I see is that if we upgrade our bitbucket version, it may have to be set again.


Tags: bitbucket-server

proxy

server
using app passwords for api call authentications for bitbucket cloud
Asked by Doug Shawhan:

I am attempting to access the bitbucket cloud REST api with the python requests module to list pull requests using an app password.

Docs at <https://developer.atlassian.com/cloud/bitbucket/rest/intro/#basic-auth> state the following regarding app passwords:

\> Basic HTTP Authentication as per [RFC-2617](https://tools.ietf.org/html/rfc2617) (Digest not supported). Note that Basic Auth is available only with username and [app password](https://bitbucket.org/account/settings/app-passwords/) as credentials.

\> - You can use them for API call authentication, even if you don't have two-step verification enabled.

I am unable to find any examples of how the app password is used. Since I am reduced to guessing, I have tried:

1. the basic auth pattern using my username and the app password, which throws a deprecation warning

2. using the app password as an api token, which gives me a "token expired" message

Is there an example somewhere?


Answers:
author: Doug Shawhan
body: def get_pull_request_data(self):

<br />

user_name = self.config\["DEFAULT"\].get("user_name")  
app_password = self.config\["DEFAULT"\].get("app_password")  
api_url = self.config\["DEFAULT"\].get("api_url")  
workspace = self.config\["DEFAULT"\].get("workspace")  
repo_slug = self.config\["DEFAULT"\].get("repo_slug")

<br />

query = f"{api_url}/2.0/repositories/{workspace}/{repo_slug}/pullrequests"  
headers = {  
"Accept": "application/json",  
}  
auth = (  
user_name,  
app_password,  
)

<br />

response = requests.request("GET", query, headers=headers, auth=auth)  
response.raise_for_status()  
return response.json()

Well, it works now. Perhaps the app_password was not available to the api immediately after I created it. Mysteries.

comments: author: sriprasanna.mg
body: Hi,

In our bitbucket data center instance we have disable basic auth for rest api calls.

With that setting, we cannot use this approach

auth = (  
user_name,  
app_password,  
)

Because we get "basic authentication disable' error message,

So how can we use the app password when basic auth is disabled?

We tried with Bearer token: but it does not work as the authentication fails.

Any help?


author: sriprasanna.mg
body: Got blinded by cookies based auth (postman).

Present situation: **Can't get auth. to work for rest api calls when basic auth is disabled**


Tags: bitbucket-cloud

cloud

password

pull-request

python

request

rest-api
Is it possible to unsecure the repository variables in case you forgot the name and password?
Asked by yosser_mahfoudh:

I'm wondering if it's possible to see the repository variables that I have secured.


Answers:
author: Mark C
body: Hi [@yosser_mahfoudh](/t5/user/viewprofilepage/user-id/3803216)

Thank you for reaching out to the community.

Unfortunately, it's not possible to un-secure a secured environment variable as it is currently designed that way.  
It is also mentioned in the [Pipelines environment variables documentation](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/) that:
> If you want to edit a secure variable, you can only give it a new value or delete it. Secure variables are stored as encrypted values.

You could also give your secured environment variables unique names so that you can easily identify them moving forward.

Hope it helps and let me know if you have further questions that I can help with.

Regards,  
Mark C


Tags: bitbucket-cloud

cloud
Bearer Auth without username and Password
Asked by rakesh goud:

Need sample code using HTTPWebRequest to call bitbucket api token in c#


Answers:
author: o_kyrdan
body: Hi [@rakesh goud](/t5/user/viewprofilepage/user-id/4885850)

<br />

Hope this [docs for OAuth consumer examples](https://support.atlassian.com/bitbucket-cloud/docs/oauth-consumer-examples/) could help you.

The example in Python (also a link to other lang) but there you could see an idea and main logic to interact with the Bitbucket API.

Cheers,  
Oleksandr Kyrdan


Tags: api

bitbucket-cloud

cloud
Hi! Can you still use your Repositories after 2024 february 15th?
Asked by pworklab:

***// sorry if my English is not fluent //
Hi my name is Midori and
I've been using bitbucket for private project***

***and I saw that there are some service that will stop service on february 15 2024*** ***was wondering what would happen to those old made repositories*** ***do i need to do something to able to continue to access on that git??*** ***I hope I'm making sense*** ***I would be very thankful if someone could help me on this*** i will leave [my email address](mailto:pworklab@gmail.com) here


Answers:
author: Christian Glockner
body: Hi Midori,

I suppose you're talking about the announcement at <https://www.atlassian.com/migration/assess/journey-to-cloud>. Are you using Bitbucket.org or your own local Bitbucket Server instance?

If you're talking about Bitbucket.org, then nothing will change due to that announcement. If you're using Bitbucket Server with a Server license, then it will continue to work fine, but you will not be able to upgrade to newer versions of Bitbucket Server that were not released at the expiration date of your Server license.

Cheers,

Christian

Premier Support Engineer

Atlassian


Tags: bitbucket-cloud

cloud

jira-service-desk-cloud
How to regularly delete branches?
Asked by Anne Pan:

Hi all,

I got a requirement that the company wants to regularly delete branches to keep like 3 latest versions or in a particular timeframe. Also, they want to set a limitation of the branch size. For example, over 1GB would be deleted.

Is there any plugin or solution that could help with this requirement?

<br />

Thanks in advance.


Answers:
author: Mikael Sandberg
body: You would need an app to do it, one that allows you to create pre hooks to check size of the commit, and that allows you to run scripts to clean up branches. The one that comes to my mind is [Scriptrunner](https://marketplace.atlassian.com/apps/1213250/scriptrunner-for-bitbucket?hosting=datacenter&tab=overview).

Please note that branches are not linked to the size. Branches are just pointers, it is commits that are increasing the repository size.

comments: author: Anne Pan
body: Thanks for the reply. I'll try scriptrunner.


Tags: bitbucket-administration

bitbucket-data-center

bitbucket-server

server
Environment variables from my project settings not properly working in my pipelines
Asked by kalib:

I am trying to use some environment variables in my bitbucket pipeline scripts and it looks like the variables are not being passed, for example:

```
- VERSION=${BITBUCKET_TAG:-${BITBUCKET_BRANCH//\//_}-latest}- IMAGE_NAME="${NEXUS_DOCKER_PRIVATE_REGISTRY_URL}/baseline-service:${VERSION}"- docker build . -t $IMAGE_NAME --pull --no-cache --label 'GIT_COMMIT_HASH=$BITBUCKET_COMMIT'
```

In that case, NEXUS_DOCKER_PRIVATE_REGISTRY_URL is my environment variable, but it's not being translated properly:

```
+ docker build . -t $IMAGE_NAME --pull --no-cache --label 'GIT_COMMIT_HASH=$BITBUCKET_COMMIT'invalid argument "$NEXUS_DOCKER_PRIVATE_REGISTRY_URL/my-service:feature_pipeline-latest" for "-t, --tag" flag: invalid reference format
```


Answers:
author: Patrik S
body: Hello [@kalib](/t5/user/viewprofilepage/user-id/3485966) ,

From the error message seems like the IMAGE_NAME variable was not populated correctly. Checking the syntax you have used in IMAGE_NAME, it seems to be correct, and testing on my repository it was correctly presenting the value.

Could you please confirm if the NEXUS_DOCKER_PRIVATE_REGISTRY_URL has not any typo when you created it in your repository settings/workspace settings ?

One thing you can also do for troubleshooting is to print the variables using **echo** after you have created them and see if the value is correct, like below :

```
- VERSION=${BITBUCKET_TAG:-${BITBUCKET_BRANCH//\//_}-latest}
- echo $VERSION- IMAGE_NAME="${NEXUS_DOCKER_PRIVATE_REGISTRY_URL}/baseline-service:${VERSION}"
- echo $IMAGE_NAME
- echo $NEXUS_DOCKER_PRIVATE_REGISTRY_URL
```

Would you please try the above and let us know the output ?

Thank you, [@kalib](/t5/user/viewprofilepage/user-id/3485966) .

Kind regards,

Patrik S

comments: author: kalib
body: Thanks, this method for validation worked for me as well. Thanks, it will make it way easier for troubleshooting.


author: Patrik S
body: Hey [@kalib](/t5/user/viewprofilepage/user-id/3485966) ,

Awesome! It's indeed way easier to investigate when printing the variable value with **echo**. Do let us know in case you have any other questions.

Kind regards,

Patrik S


Tags: bitbucket-cloud

bitbucket-pipelines

cloud
List all files in repository or branch of repository using API 2.0
Asked by BEN MOUSSA Anis-ext:

Hello Community!

I want to list all the files in repository usin API 2.0

the goal is to review extensions and alert users if they are pushing unauthorized data

I need to monitor the file the user and the repository

Thanks


Answers:
author: o_kyrdan
body: Hi [@BEN MOUSSA Anis-ext](/t5/user/viewprofilepage/user-id/4884487)

Thank you for your question!

It could be your case to use [Bitbucket Pipe: Git secrets scan: Scan your files for hardcoded sensitive data and create a security report.](https://bitbucket.org/atlassian/git-secrets-scan)  

> By default, the pipe will scan your files for hardcoded AWS credentials and create a security report with annotations for each found credential.
>
> If a value for `CUSTOM_PATTERN` is provided, it will scan for and AWS credentials **and** `CUSTOM_PATTERN`.
>
> If the `CUSTOM_PATTERN` is not provided, it will scan for AWS credentials only.

In the repository turn on Bitbucket Pipelines and add the pipe:

Run a scan for AWS credentials:  

```
script:  - pipe: atlassian/git-secrets-scan:0.6.0
```

or

Scan custom secrets using a pattern that matches  
Bitly's secret key file (`^R_[0-9a-f]{32}$`):  

```
script:  - pipe: atlassian/git-secrets-scan:0.6.0    variables:      CUSTOM_PATTERN: '^R_[0-9a-f]{32}$'
```

Best regards,  
Oleksandr Kyrdan


author: Karthick S
body: Hello [@BEN MOUSSA Anis-ext](/t5/user/viewprofilepage/user-id/4884487)

Welcome to the Atlassian Community.

In Bitbucket Cloud, you may try this [API to Get file or directory contents](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get) in the repository.

Let us know if you have any queries.

Kind regards,

Karthick S


Tags: bitbucket-cloud

cloud
Reporting sonarcube analysis even if the build fails
Asked by Sandeep.Dash:

Is there a way to report code analysis on sonarcube dashbaord even if the build fails? Is there a way to write a script in yml file to do the above? Please let me know.


Answers:
author: Patrik S
body: Hey [@Sandeep.Dash](/t5/user/viewprofilepage/user-id/4309840) ,

My suggestion would for you to make use of the **after-script**functionality of Bitbucket Pipelines. With after-script you can define one or commands to be executed as soon as your step is completed, regardless if the step failed or succeed.

Please find below an example of using after-script keyword :

```
`pipelines:  default:    - step:        name: Build and test        script:          - npm install          - npm test        after-script:          - echo "This is my first after script command"`
`          - echo "This is my first after script command"`
`          - ./my_script.sh   #invoking a script`
```

In the example above, the 3 commands of **after-script** section will be executed both if the prior **npm** commands fail or succeed. For more details about the after-script syntax you can refer to [this documentation](https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/#after-script).

If you want the after-script to only be executed in one of these scenarios (only when step succeed or only when the step failed) you can make use of the environment variable BITBUCKET_EXIT_CODE - values can be 0 (success) or 1 (failed) - and create an if statement in your YML, like below :

    `after-script:`
    `  `- if [ "$BITBUCKET_EXIT_CODE" != 1 ]; then exit 0 ; fi  - echo "This command will only be executed if the step failed"

You can also make use of pipes in the after-script section. Sonar has developed some pipes that can be used in Bitbucket pipelines which might be useful for your use-case :

* [https://bitbucket.org/product/features/pipelines/integrations?\&search=sonar](https://bitbucket.org/product/features/pipelines/integrations?&search=sonar)

Hope that helps to address your questions. Do let us know in case you have any doubt.

Thank you, [@Sandeep.Dash](/t5/user/viewprofilepage/user-id/4309840) .

Kind regards,

Patrik S


Tags: bitbucket-cloud

cloud
Default branch for Pull Requests
Asked by Rob van der Lee:

One of our repositories has troubles getting the default branch to change, specifically in the PR window. We've set the default branch in the "Advanced" section under "Repository details" in the settings:

![default_branch_selected.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/193445i27360D48C072E508/image-size/large?v=v2&px=999 "default_branch_selected.jpg")

Then if we make a new PR it does not show the correct default branch. On other repositories this has worked fine for us but I cannot figure this one out as to why I cannot change this repository.

![pull_request_shows_wrong_branch.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/193446iF796577E34B9DEC0/image-size/large?v=v2&px=999 "pull_request_shows_wrong_branch.jpg")


Answers:
author: Caroline R
body: Hi, [@Rob van der Lee](/t5/user/viewprofilepage/user-id/4883575), welcome to the community!

For pull request workflows, the default target branch will be the one set as the **Development branch** on your **Branching model**(Repository settings \> Branching model). There, you can select the main branch (the one you defined on your advanced settings) or a specific branch.

In this case, could you please confirm which branch is defined as the **development branch** in this repository?

Please feel free to share any additional questions or concerns regarding this case.

Kind regards,   
Caroline

comments: author: Rob van der Lee
body: Hi, thanks for the timly reply. You are absolutly right. That fixed my problem. The reason why all other repositories did not have this problem is because they were all defaulting to the **"Use main branch"** option as where this specific repository was set to **"master"**.

Thanks so much :)


author: Caroline R
body: Hi, Rob! Thanks for your confirmation, I'm glad to help!


Tags: bitbucket-cloud

branch

cloud

default
Request for Garbage Collection
Asked by Martin Jirlow:

Hello!  

We have an issue with a rather large repository, and have been able to clean up our history a bit but the repository size is still reported as quite large. I was wondering if it is possible to ask for manual garbage collection on the repository, as suggested in the [Atlassian support guide](https://support.atlassian.com/bitbucket-cloud/docs/reduce-repository-size/)?

The repository name in question starts with '20'. That should be enough for support staff to identify it.

Thank you!


Answers:
author: Theodora Boudale
body: Hi [@Martin Jirlow](/t5/user/viewprofilepage/user-id/4883080),

I ran a git gc for this repository, its size is 160.5 MB now. Does this agree with the size of your local repo if you run **git count-objects -Hv**?

We have a feature request to allow users to trigger a git gc for their remote repos:

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

You can add your vote to this feature request (by selecting the **Vote for this issue** link) if you'd be interested in that feature, and you can also add yourself as a watcher (by selecting the **Start watching this issue** link) if you'd like to get notified via email on updates.

Kind regards,  
Theodora

comments: author: Martin Jirlow
body: Thank you!  

Yes this does agree with count-objects. I will keep an eye on this feature request.  

Kind Regards,  
Martin


author: Theodora Boudale
body: You are very welcome! Please feel free to reach out if you ever need anything else.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud

garbage-collection
Invitation email
Asked by yeenfei:

One of the recent new employee is unable to receive the invitation email after administrator remove invitatiom and re-invite him (as he is getting error on "too many attempt to reverify the account")


Answers:
author: Caroline R
body: Hi, [@yeenfei](/t5/user/viewprofilepage/user-id/139336),

I saw that you created a ticket with our support related to the same question, so to avoid any possible misunderstandings or miscommunication that may arise from discussing the same matter on two different platforms, let's focus on the ticket instead.

Once the ticket is resolved, feel free to share the resolution here to help other community members that may have the same issue.

Kind regards,  
Caroline


Tags: bitbucket-cloud

cloud