youngmon/atlassian-qna huggingface dataset:
Bitbucket Cloud API endpoints with app password
Asked by mgnavarrete:

Hi!

I am trying to managed my Bitbucket Cloud Workspace by the API using a oauth consumer but I have just found out that there are a few endpoints where I must use app password:

- [Update group permissions for a repository](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-permissions-config-groups-group-slug-put)

- [Update user permissions for a repository](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-permissions-config-users-selected-user-id-put)

![Screenshot from 2023-03-23 17-34-08.png](https://community.atlassian.com/t5/image/serverpage/image-id/247360iC4B5E347D274B2C3/image-size/large?v=v2&px=999 "Screenshot from 2023-03-23 17-34-08.png")

The thing is, app password are own by an account meanwhile oauth consumer can be created at workspace level. The idea is not to use personal accounts because at some point these accounts can be deleted and generate a problem in the autommation so instead we would rather use the oauth from the workspace that is going to be always active.

Therefore, this two endpoint are a big problem for us due to we cannot access by oauth. I wanted to ask if this can be solved by a workaround or if there is some plan to allow to access these endpoints by oauth? Maybe an other solution could be allow to create app passwords at workspace level.


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

Thanks for reaching out to Atlassian Community!

I'm afraid that currently, the repository permissions endpoints indeed don't support using OAuth tokens for authentication, only app passwords. We do have a feature request to add the ability to authenticate with OAuth consumers for those endpoints, which you can check in the following link :

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

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.

Unfortunately, there's no workaround at this moment other than using App Passwords for authentication.

Thank you, [@mgnavarrete](/t5/user/viewprofilepage/user-id/5124621) !

Patrik S

comments: author: mgnavarrete
body: Thanks for your answer Patrik, it has been very useful :)


Tags: bitbucket-cloud

cloud
There's no pip on atlassian/default-image:4
Asked by ???:

Hello!

I couldn't find pip on the default image.

How could I install it without using apt and cache the installed pip?


Answers:
author: Erez Maadani
body: Hi [@???](/t5/user/viewprofilepage/user-id/5176117)

For your question, since you don't want to use apt, you can either download python source code and build it locally or set up a similar ubunto 22 server with the required python modules and copy the files from there.

I strongly recommend against both options.

The recommend way would be to use a docker image which contains all your dependencies. You can either use it as the image which runs your pipeline step, or as the artifact of your build, and then pass it to next step as part of your artifacts or as part of your cache.

Have a look at:

1. <https://support.atlassian.com/bitbucket-cloud/docs/use-artifacts-in-steps/>
2. <https://support.atlassian.com/bitbucket-cloud/docs/cache-dependencies/>
3. <https://support.atlassian.com/bitbucket-cloud/docs/run-docker-commands-in-bitbucket-pipelines/>

comments: author: ???
body: I agree with you totally, but I was curious, why the default image contains only python except pip. I thought there would be a special way to get pip. But it was not :-)

Would you please tell me why the default image doesn't contain pip?


Tags: bitbucket-cloud

cloud
Migrate old pull requests from gitlab/github/gitea
Asked by Daniel Pasch-Sannapiu:

Bitbucket Cloud has a Migration Assistant and that works fine for Bitbucket Server.   

But what if I want to migrate from another type of Git host?  

Is there an API I can use to submit old pull requests on e.g. my old Gitlab instance. So they also show up in Bitbucket Cloud?   

I know this won't work "out of the box" I don't expect it to, but If I can just consume the same APIs that the Migration Assistant consumes I could achieve the same end result with a little bit of code.


Answers:
author: Robert Wen_ReleaseTEAM_
body: Here's the Bitbucket Cloud REST API Documentation: <https://developer.atlassian.com/cloud/bitbucket/rest/intro/>


Tags: bitbucket-cloud

cloud
Pipelines - Move to next step after successfully running a container.
Asked by obsydian:

Hi,  

I am building a pipeline to build and distribute a dockerised application. I am able to get the container built and running but because it's essentially an open-ended container that runs and runs I need to ensure it is running and then stop the container and move to the next steps in the pipeline.  

Is there any way to do this? The reason I want to ensure that it runs is I have experienced issues in the past where dependencies in parts of the Dockerfile stages were updated and caused the container to build but not run.

Currently, I have tried curl'ing the localhost but that doesn't get triggered. the container runs and as it's long-standing it therefore just stays on that command indefinitely.


Answers:
author: Erez Maadani
body: Hey [@obsydian](/t5/user/viewprofilepage/user-id/1911837)

It's possible and mainly depends on your definition of "successful run" of your image. Does "successful" mean that the container run for X seconds? or reached a certain point in the code? something else?

Basically, you would need to:

1. Run your container in the background, using "-d" flag.
2. Run "sleep" in your step to let your container reach the desired point.
3. Check if the container reached the desired point. Depending on your need, it might be checking if the container is still running, checking the container's logs, etc'.
4. Exit the step with a suitable exit code

Hope that helps

comments: author: obsydian
body: By runs I just need to check it doesn't error on running. I just need to check that the server is up and running and that could be done by checking the container log which shows the following.

```
[info] The server listening at port: 4000
```

Or by pinging the healthcheck endpoint. I'm not sure which is preferable or how I go about doing this as the next step in the pipeline. Any comments or leads welcome but thanks for your input already.


Tags: bitbucket-cloud

bitbucket-pipelines

cloud

docker
adding stage step giving error
Asked by manish reddy:

pipelines:  
branches:  
main:  
- stage:  
name: Build and test  
deployment: develop  
steps:  
- step: null  
name: Build and package  
script:  
- apt-get update \&\& apt-get install -y zip  
- zip -rj code.zip ./lambda_code/\*.\*  
- echo "deploy to develop environment"  
artifacts:  
- code.zip  
- step:  
name: Update Lambda code  
script:  
- pipe: atlassian/aws-lambda-deploy:0.2.1  
variables:  
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}  
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}  
AWS_DEFAULT_REGION: us-east-1  
FUNCTION_NAME: my-lambda-function  
COMMAND: update  
ZIP_FILE: code.zip


Answers:
author: Patrik S
body: Hello [@manish reddy](/t5/user/viewprofilepage/user-id/5177642) ,

Welcome to the Community!

I think the indentation of the YML file you shared is a bit off, which might be causing the error when running your pipeline. I've made some adjustments and the following should be a valid YML file :

```
pipelines:
  branches:
    main:
      - stage:
          name: Build and test
          deployment: develop
          steps:
            - step: 
               name: Build and package
               script:
                - apt-get update && apt-get install -y zip
                - zip -rj code.zip ./lambda_code/*.*
                - echo "deploy to develop environment"
               artifacts:
                - code.zip
            - step:
                name: Update Lambda code
                script:
                  - pipe: atlassian/aws-lambda-deploy:0.2.1
                    variables:
                      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
                      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
                      AWS_DEFAULT_REGION: us-east-1
                      FUNCTION_NAME: my-lambda-function
                      COMMAND: update
                      ZIP_FILE: code.zip
```

I would also recommend using the [Validator for bitbucket-pipelines.yml](https://bitbucket-pipelines.atlassian.io/validator) to check and fix any syntax error you might have in your YML file before pushing it to your repository.

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

Thank you, [@manish reddy](/t5/user/viewprofilepage/user-id/5177642) !

Patrik S


Tags: bitbucket-cloud

cloud
Slack notifications and notification types for deployments
Asked by Kelly:

Hello,

There are currently only 3 notification types available for deployments:

deployment succeeded

deployment stopped

deployment failed

Is it possible to send out a notification when a deployment has started?

Also can notifications be sent only if the above actions are done on a specific environment?

Thanks


Answers:
author: Ben
body: Hey Kelly,

This is unfortunately not yet possible, however, we have an existing feature request logged by our customers with our development team - please feel free to "Watch" this to receive updates related to it and "Vote" to improve its visibility in regard to customer demand:

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

Cheers!

- Ben (Bitbucket Cloud Support)


Tags: bitbucket-cloud

cloud

slack
App Passwords - repository not found
Asked by Andrew Chalk:

On Ubuntu I enter:

```
git remote set-url origin https://{username}:{app pw}@bitbucket.org/Andrew_Chalk/exhibit.git
```

with {} parameters entered.

then:

git push origin master

I get:

"remote: You may not have access to this repository or it no longer exists in this workspace. If you think this repository exists and you have access, make sure you are authenticated.  
fatal: repository '<https://bitbucket.org/Andrew_Chalk/exhibit.git/>' not found"  

I have spent a time on this and cannot figure out what I am doing wrong.   

Help appreciated.


Answers:
author: Syahrul
body: G'day [@Andrew Chalk](/t5/user/viewprofilepage/user-id/4935619)

There was no repository on our from the URL you shared. I suspect you are using the wrong workspace name; hence it's failing to locate the repository.

Could you open the affected repository in UI, click clone at the right side corner, and select HTTPS, then use the URL to change your local remote URL?

You can also check our documentation [here](https://support.atlassian.com/bitbucket-cloud/docs/change-the-remote-url-to-your-repository/) on the right format when changing git remote URL.

Additional note, you don't need {} parameter in the URL.

Cheers,  
Syahrul


author: Andrew Chalk
body: That worked, but i am baffled why that URL is correct. Here is a screenshot of Bitbucket showing the workspace name as "Andrew_Chalk", yet the URL with that does not work:  

![Screenshot from 2024-03-16 11-30-24.png](https://community.atlassian.com/t5/image/serverpage/image-id/312508iAA622FF9A58D6787/image-size/large?v=v2&px=999 "Screenshot from 2024-03-16 11-30-24.png")

Thanks.

comments: author: Syahrul
body: Hey [@Andrew Chalk](/t5/user/viewprofilepage/user-id/4935619)

There might be a mix-up between your workspace name and workspace ID, two distinct entities.

Your workspace name is "andrew_chalk", whereas your workspace ID is "achalk0". For git operations, we utilize the workspace ID, not the workspace name. Therefore, your URL appears invalid because it contains the workspace name "andrew_chalk" instead of the correct workspace ID, "achalk0".

To view your workspace name and ID, you can head to your workspace settings. Both should be listed there.

Regards,  
Syahrul


author: Andrew Chalk
body: Exactly the problem!

I appreciate your help on this.

- A


Tags: app

bitbucket-cloud

cloud
Problem with using image and pipe on Self hosted runner
Asked by Peter Jeong:

I want to run custom pipes or image with self hosted runner for deploy to on-prem.

Is this not supported?

If not, how should I use it?


Answers:
author: Patrik S
body: Hello [@dahoon jeong](/t5/user/viewprofilepage/user-id/5033920) ,

Thank you for reaching out to Atlassian Community!

As [pipes](https://bitbucket.org/product/features/pipelines/integrations) rely on docker containers to work, it's only possible to run pipes when using [Linux Docker self-hosted runners](https://support.atlassian.com/bitbucket-cloud/docs/set-up-and-use-runners-for-linux/). Other types of runners that run directly in a shell session, such as [macOS Runners](https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-macos/) , [Windows Runners](https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-windows/) and [Linux Shell runners](https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-linux-shell/), do not currently support using pipes.

Having said that, if you are already using Linux Docker self-hosted runners, you should be able to run pipes as usual, using the same syntax you would use if your build was running in the cloud. Please find below an example YML definition :

```
pipelines:
  default:
      - step:
          name: Using a pipe with Linux Docker runner
          runs-on:
           - 'self.hosted'
           - 'linux'
          script:
            - echo "This is an example step"
            - pipe: atlassian/email-notify:0.8.0
              variables:
                USERNAME: 'myemail@example.com'
                PASSWORD: $PASSWORD
                FROM: 'myemail@example.com'
                TO: 'example1@example.com, example2@example.com, example3@example.com'
                HOST: 'smtp.gmail.com'
```

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

Thank you, [@dahoon jeong](/t5/user/viewprofilepage/user-id/5033920) !

Patrik S

comments: author: Peter Jeong
body: Hello [@Patrik S](/t5/user/viewprofilepage/user-id/4603309)

really thanks your kindness answer.

But, there is an extra planning to able pipes and image on linux shell runner?

Thank you, [@Patrik S](/t5/user/viewprofilepage/user-id/4603309)


Tags: bitbucket-cloud

bitbucket-pipelines

cloud
How to display files in reverse order when browsing folders in Bitbucket?
Asked by jli:

Hello, a folder in my repo can have more than 1000 files. How can I display the files in reverse order so that I can see the latest files added? I've tried appending sort to the url but it does not work, and not sure if "path" is the right field to sort on. Any help is appreciated. Note: this is in Bitbucket Server instead of Bitbucket Cloud.

<https://bitbucket.xxxx.com/projects/HQS/repos/hqs/browse/Databases/Measure/ChangeScripts?at=refs%2Fheads%2Fdevelop>**\&sort=-path**

![csfiles.png](https://community.atlassian.com/t5/image/serverpage/image-id/247149i28C6BE683BC6A0B6/image-size/large?v=v2&px=999 "csfiles.png")


Answers:
author: Ben
body: Hello,

Can you please clarify - are you experiencing this issue in Bitbucket Cloud or in Bitbucket Server? The API command/web address seem to relate to server, but the screenshot almost looks like Cloud.

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: jli
body: This is in Bitbucket Server. Screenshot is from Bitbucket Server.


author: Ben
body: Thanks for letting me know, I've re-labelled the ticket as I cannot assist you with this - this would be best served by a member of our Server community.

Cheers!

- Ben (Bitbucket Cloud Support)


Tags: bitbucket-server

rest-api

server
Can't use Workspace Access Token to create a branch subject to branch permissions
Asked by Jay Seletz:

I have a script that creates branches in Bitbucket in numerous repos. Until now I've been using a dedicated Bitbucket User to do this. I recently switched to using the new Workspace Access Token feature. This worked until I tried to create a branch in a repo with Branch Permissions that limit write access to certain branch types to a single group (which that dedicated user I'd been using previously has been in).   

Using the Access Token, which has the "repository:write" scope, the push to create the new branch fails with \`remote: Permission denied to create branch\`. I believe it's due to the branch permission. Should this work? Is there a way to give the Auth Token user permission here?


Answers:
author: Nathan Hitchman
body: Hi, did anyone find the way around this? I have the exact same problem.

Documentation mentions nothing.


author: Martin Karing
body: I encountered the very same issue. I'm trying to push changes to a repository using a workspace access token, but I'm blocked by the branch restrictions. Those branch restrictions are required for the normal operations done by the developers, the script is required to bypass those.

I tried to get this working using the access tokens, but failed so far. I tried adding the access token to the branch restrictions as exception, both by the user interface of bitbucket and by the API of bitbucket. Both methods failed.


author: Jay Seletz
body: Just did some targeted testing. A branch permission restricting edit will prevent both creating a branch matching the restriction, as well as pushing changes. How can an Access Token be used in this case?


Tags: bitbucket-cloud

cloud
Reference issues in your development work feature problem
Asked by Michele Belloni:

Does this feature still work?  
Until two days ago, putting the ticket key in the title, then in the pull request automatically linked the JIRA, now no longer.


Answers:
author: Patrik S
body: Hello all,

We had a temporary incident that was making the link between Bitbucket Pull Requests and Jira issues not work properly.

Our engineering team already implemented a fix for this bug ([AUTO-666](https://jira.atlassian.com/browse/AUTO-666)) and the link between PRs and Jira issue should be working as usual again.

If you are still running into any issues with the linking of your Issues, please let me know.

Thank you!

Patrik S


author: juan_calderon
body: This is happening to me and my team too.


Tags: bitbucket-cloud

cloud
Spam on issue tracker
Asked by ?eljan:

Hi,

Can you please prevent spam on our issue tracker here: <https://bitbucket.org/bookingwp/woocommerce-appointments/>

Not sure what to do as there is no way to bulk delete it.

Regards,

?eljan


Answers:
author: Patrik S
body: Hi [@?eljan](/t5/user/viewprofilepage/user-id/4912934) ,

Thanks for reaching out to the Community!

Our engineering team can help with either:

* flag issues as Spam
* completely remove issues

**Please keep in mind that there is a possibility for false positives to be included in the flagging or removal.** If you are concerned about irreversible loss, we would suggest requesting flagging, so that you can review the issues.

Before we proceed, ++please make your issue tracker private++ (*Repository Settings \> Issue Tracker \> Private issue tracker*) to prevent the creation of new spam issues. I will post an update here once our engineering team has mitigated the issue and when it's safe to make your issue tracker public again.

Afterward, please let us know whether you would like us to proceed with flagging issues as spam in your issue tracker or removing them :

* **Removal**: If you would like us to proceed with the removal, please provide a range of issue IDs to remove. You could also include issues that you want to be excepted from this range. E.g. for the range "200-3700 EXCEPT 3256-3260" we will remove issues with id from 200 until 3700, except for the issues in the range 3256-3260. Ranges should be fully inclusive, meaning the number on both ends will be removed.
* **Flagging as Spam:**If you would prefer to mark the issues as Spam, so you can review them later, please provide an Issue ID as a starting point. All the issues after the starting point ID will be marked as Spam.

Let me know in case you have any questions.

Thank you, [@?eljan](/t5/user/viewprofilepage/user-id/4912934) !

Patrik S


author: jakimowb
body: Dear [@Patrik S](/t5/user/viewprofilepage/user-id/4603309)   

I have similar problems, some of my open source repositories are flooded with spam issues and the missing bulk-delete/flag-as-spam option makes handling this very complicated.  

If possible, please delete the following issue ranges:

<https://bitbucket.org/jakimowb/bit-flag-renderer/issues> #16-250  
<https://bitbucket.org/jakimowb/eo-time-series-viewer/issues> #117-402  
<https://bitbucket.org/jakimowb/virtual-raster-builder/issues> #27 - 178

Thank you,

Benjamin


Tags: bitbucket-cloud

cloud
What does the badge count on the Commit icon mean? Why did it show up after recent update?
Asked by John Black:

Up until a recent update (Version 3.0 (199)), I never saw a count badge on my Commit icon in the upper left of my toolbar. Of course, I am used to seeing a count badge on my Push icon, when I have committed locally but not yet pushed to the origin. But I have never seen the count badge on my Commit icon.

1. What does it mean? I can't conceive of what it relates to.

2. Can I reset it? (of course, this depends on what it means)

Thanks!


Answers:
author: bgannin
body: Hi John,

This is an intentional change. We moved the "modified files" count from the sidebar to the toolbar for consistency with the other items and with Windows. When you commit or discard your changes, it will reset as the sidebar's count did before. If not, that's a bug.

Brian Ganninger  
Senior Mac Developer, Sourcetree

comments: author: John Black
body: Got it. Perfect. Can see it now Thank you very much.


author: Manju
body: 1. This is the same count that used to appear next to the file status side bar item. It shows the number of files that are currently not committed and includes the number of modified, added and removed files that show up if you were to run git status on terminal.

2. It goes away when your repository is pristine (either you commit all the files or undo all changes).


Tags: mac
Why can't I log in to SourceTree?
Asked by kris8360:

Hi, my problem is, that I can't clone my bitbucket (!) repos in to sourcetree at all.

I tried adding my bitbucket account, with both oauth, and basic, my account is recongised successfully both ways, and I can see all my repositories in the list.

But when I try to clone any of them, I keep getting a window where I have to log in to my atlassian account. Despite giving the right username and password, I keep getting that window in an infinite loop.

I tried to clone without adding my account, just over HTTPS, but same problem.

I don't understand what is the problem, I can clone any of my bitbucket repos with smartgit without problem over HTTPS.

I can clone my github repositories in SourceTree without any problem, but not my bitbucket repositories.

HTTPS is fine for me, I don't want to bother with SSH, so my question is how can I solve this issue?

Thanks


Answers:
author: kris8360
body: I got it working, uninstalling SourceTree doesn't delete everything, I had to delete the Atlassian folder from AppData, then reinstall again.


Tags: bitbucket

bitbucket-cloud

cloud