youngmon/atlassian-qna huggingface dataset:
How to get logged in users email when running pipeline
Asked by Jani Ruohomaa:

Hi,

How do I get the email of the logged in user in bitbucket pipelines so that I can send email to the user with email-notify (<https://bitbucket.org/atlassian/email-notify/src/master/>)

I tried this:

```
curl -X GET -g "https://api.bitbucket.org/2.0/user/emails" | jq --raw-output '.values[0].email'
```

but it does not work. It seems it does not return anything

I also tried this endpoint but it does not contain the email address  

```
https://api.bitbucket.org/2.0/users/{selected_user}
```

What is the context that the pipeline is run, it is not the logged in user ?

-Jani


Answers:
author: Theodora Boudale
body: Hi Jani,

I'm not really sure what you mean by 'logged in user in bitbucket pipelines'. Do you mean the user who triggered that build?

At the moment, I'm afraid that it is not possible to retrieve emails of other users via API.

Emails of workspace members are visible to workspace admins in workspace **Settings** \>\> **User groups** \>\> after selecting a specific User group.

However, they cannot be retrieved via API yet. We have an open feature request for this, you can add yourself as a watcher if you'd like to get notified via email on updates:

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

The API call you mention in your question:

```
curl -X GET -g "https://api.bitbucket.org/2.0/user/emails" | jq --raw-output '.values[0].email'
```

needs authentication.

You'll need to include in the call *-u username:password* with the credentials of your user. You could create repository variables for the username and password and then execute this call from the build, but it will return the email of your own user (that endpoint returns all the authenticated user's email addresses)

Kind regards,  
Theodora

comments: author: Jani Ruohomaa
body: Yes, the user that is running the build. I was kind hoping that I could just call

```
https://api.bitbucket.org/2.0/user/emails
```

and it would return me my email address since I am the one running the pipeline but I realized that I need to authenticate separately for that (with the same credentials that I logged in to bitbucket :-))

I assume you get the email from somewhere since if the pipeline fails I get an email that it has failed


Tags: bitbucket-pipelines

cloud

email
Forwarding Client IP for git operations over SSH?
Asked by Bailey Waldorf:

Hello,

We have a Bitbucket Data Center cluster behind a load balancer. When users clone over SSH, the Bitbucket logs see the IP address as the load balancer rather than the user. This is because TCP connections don't allow a header to forward the client IP and instead just use the load balancer IP. This is troublesome when inspecting the access logs and not being able to associate a user to their IP address.

We have the option of adding the client IP to the TCP packet but Tomcat cannot parse the whole packet without changes being made. Does anyone have a workaround so we can see where our SSH requests are coming from?


Answers:
author: Moses Ebrahimi
body: Hi [@Bailey Waldorf](/t5/user/viewprofilepage/user-id/3797397)

Did you find any solution/workaround for this?

Thanks

Moses


Tags: bitbucket-server

log

server
Generate a OAuth for specific repositories
Asked by amartinez:

I would need to generate an OAuth Consumer key and secret for a certain repository only.  
As far as I've seen, to access a repository I need to generate a key in the workspace to read repositories, but this grants access to ALL the repositories in the workspace.

Could I select only the repositories that I'm interested in instead of them all? It'll be so helpful. If not, I can't use the Bitbucket API.

Thank you,


Answers:
author: Theodora Boudale
body: Hi [@amartinez](/t5/user/viewprofilepage/user-id/4196197) ,

I'm afraid that this is not possible, we have a feature request for this in our issue tracker:

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

I'm not sure what is your use case, what exactly you are building, and which flow you are using for generating access tokens (see here for the different flows <https://developer.atlassian.com/bitbucket/api/2/reference/meta/authentication>).

Keep in mind though that with 3-LO flows, 'Repositories:Read' for example grants read access to all the repositories to which the authorizing user has access.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud

jira-software

jira-software-cloud

oauth
How to create comment or tasks in pull requests with Scriptrunner from Bitbucket v5.9.0?
Asked by rlandes:

I'd like to create tasks when a pull request is created via the Custom Event Handler feature from Bitbucket Scriptrunner, but I couldn't manage to find how to do it so far. I did find solutions on this website but they seem not to apply in v5.9.0, for example this one: <https://community.atlassian.com/t5/Bitbucket-questions/How-to-auto-comment-Pull-Requests/qaq-p/266093>

Even after replacing

```
pullRequestService.addComment
```

with

```
commentService.addComment
```

and after importing the right interface, since I noticed the function switched interface between versions (<https://docs.atlassian.com/bitbucket-server/javadoc/5.9.0/api/reference/com/atlassian/bitbucket/comment/CommentService.html>), it didn't work, I got the following message in the logs:

groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy454.addComment() is applicable for argument types: (Integer, Long, String) values

The solutions I found on other questions got the same fate, and I'm still unable to automatically create tasks or even comments right now.

Any solution? Thanks a lot in advance.


Answers:
author: Robert Giddings [Adaptavist]
body: Hi [@rlandes](/t5/user/viewprofilepage/user-id/4183974) ,

Using ScriptRunner for Bitbucket, you can also add tasks to Pull Requests using a built-in script. Here is the documentation: <https://docs.adaptavist.com/sr4bib/latest/features/listeners/built-in-listeners/add-tasks-to-new-pull-requests>

Does this help? Or do you need something more custom?

Kind regards,

Robert Giddings,

Product Manager, ScriptRunner for Bitbucket


Tags: atlassian-marketplace

bitbucket-server

event-listener

pull-request

scriptrunner

server
Daily board snapshot emails?
Asked by Scott A Gasparick:

I would like to automate sending a board snapshot every weekday morning. The default option from the dropdown automation menu only allows for selecting one day.

I have tried using the general automation butler to generate reports, which I CAN set up to send every weekday, but can't find a way to create the snapshots.

Is this possible![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/185293iB7DF9B6167EE0B5F/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/185294i4F0DEF0A8E637D28/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/185295iBFB77539A292F18A/image-size/large?v=v2&px=999 "image.png")


Answers:
author: Michael Pryor
body: Can you add some screenshots? Not sure I'm following which features you are using.

comments: author: Scott A Gasparick
body: I added screenshots.


author: Michael Pryor
body: See that link at bottom of last screenshot? "For more automation". You need to create a scheduled command that sends the report (it's under the Other actions in Butler).


author: Scott A Gasparick
body: I went to that screen, and could get it to send a text report, but not a snapshot.

I first generated a report, and then included that report in the automated email.

The report, however was/is just a text list of all of the cards not a snapshot.

How do I send a snapshot like the snapshot shortcut?


author: Michael Pryor
body: The email report Board Snapshot in that menu just creates a special scheduled command. Go ahead and set it up for one day and then click the button to edit it and you'll see the details that it uses. I think it all uses a special variable called {$report_html} or something similar.


author: Scott A Gasparick
body: Ok. I will try that. Thanks.


author: Scott A Gasparick
body: Update: This worked perfectly.


author: Ajinkya Khedkar
body: want to do it every day
How to add formatted code inside table cell?
Asked by dpe-ezrarice:

I'm trying to add a formatted json object as a code block inside a table cell and BitBucket just won't render the markdown correctly, but my VSCode render looks just fine. What is the proper syntax for BitBucket?

My markdown looks like this:

\| Message ID \| Description \| Format \|

\|:---:\|:--- \|:--- \|

\| \*\*4\*\* \| Regular data transmission \| \<pre lang=json\>{\<br\> "message_id": 4, \<br\> "cellular_imei": 123456789012345,\<br\> "iridium_imei": 123456789012345,\<br\> "device_logged_time": "2020-05-13 06:36:05"\<br\> "payload": {\<br\> "conductor_current_avg": "",\<br\> "conductor_current_rms": "",\<br\> "rssi_level": "",\<br\> "board_temperature": "",\<br\> "x_tilt": "",\<br\> "y_tilt": "",\<br\> "storage_capacitor_voltage": "",\<br\> "rangefinder_height": "",\<br\> "conductor_temperature": "",\<br\> "ground_temperature": ""\<br\> }\<br\>}\</pre\> \|

Should render as

![formatted_markdown.PNG](/t5/image/serverpage/image-id/122256i17721A68185586BE/image-size/large?v=v2&px=999 "formatted_markdown.PNG")

But is instead rendered as plaintext.


Answers:
author: Soumyadeep Mandal
body: Hi [@dpe-ezrarice](/t5/user/viewprofilepage/user-id/4195563) ,

Welcome to the community!

Please check out these links

<https://community.atlassian.com/t5/Bitbucket-questions/Formatting-code-block-inside-table-cell-in-MD/qaq-p/905005>

<https://bitbucket.org/tutorials/markdowndemo/src/master/>

comments: author: dpe-ezrarice
body: [@Soumyadeep Mandal](/t5/user/viewprofilepage/user-id/3861721)Thanks for the reply. Unfortunately the first link you shared does not have an answer. It appears to be the same issue, but without a clear answer or indication that BitBucket will ever support HTML elements inside code blocks. The second link is a generic documentation of how to use different markdown styles, but again does not answer my question.

The issue here is that BitBucket claims to support the CommonMark Spec found at <https://spec.commonmark.org/0.29/> but they haven't updated their documentation on how to implement escaping HTML elements. Their documentation references using "safe_mode" which was deprecated years ago when they were supporting python 2.x.

The reason I have to use HTML elements inside the code block is to "prettify" the json object for readability. I could alternatively write the entire thing as a single line code block, but that would lose a lot of value in clean documentation.

My markdown renders perfectly in GitHub but fails in BitBucket. At this rate I will be moving all of my versioned code to GitHub and paying for their service instead of supporting BitBucket.

I'd love to be proven wrong on why this doesn't render as it should, but as it stands, BitBucket has failed to deliver.


Tags: bitbucket-cloud

cloud

markdown
I stopped receiving bitbucket email notifications
Asked by Patrick Yee:

Suddenly I am not able to receive email notifications from bitbucket. My email address is patrick.yee@gmail.com.

Very much like <https://community.atlassian.com/t5/Bitbucket-questions/I-stopped-receiving-bitbucket-email-notifications/qaq-p/1088558>. And the comment in that thread recommends us to report as individual questions.


Answers:
author: Theodora Boudale
body: Hi [@Patrick Yee](/t5/user/viewprofilepage/user-id/2506690) ,

I checked in our system and I found a hard bounce event for this email created on 14th December 2020 with the message

```
550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces.
```

I assume that this was because of the Google outage that day. A Bitbucket email was most likely sent during the outage and we received a hard bounce event in response, which indicates permanent failure.

I went ahead and removed that event, you should be able to receive Bitbucket notifications from now on.

Please feel free to let me know if things are ok now and if you need anything further.

Kind regards,  
Theodora

comments: author: Patrick Yee
body: It works now. Thank you very much for your help, Theodora.


author: jlinn5732
body: Hi, [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) . I'm experiencing the same issue, presumably due to the same gmail outage. Would you mind removing the hard bounce event for my address (blackhawk5732@gmail.com), as well? Thanks!


author: Theodora Boudale
body: [@Patrick Yee](/t5/user/viewprofilepage/user-id/2506690) , that's good to hear, you are very welcome.

[@jlinn5732](/t5/user/viewprofilepage/user-id/3524970) , of course. I could see the same issue with your email as well. I removed that hard bounce event, so things should work as expected now (please feel free to let me know if that's not the case).


author: Joseph Linn
body: Seems to be working now. Thank you!


author: Merrilee Miller
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) would you check mine as well?

Email is: merrileeamiller@gmail.com

Thank you in advance!


author: Theodora Boudale
body: Hi [@Merrilee Miller](/t5/user/viewprofilepage/user-id/4198020) , I can see some hard bounce events in our logs for your email, earlier today. However, I see that most recent emails have been delivered, and it looks that the issue may have been resolved without my intervention. Could you please confirm if you have received most recent notification emails from Bitbucket Cloud?


author: Merrilee Miller
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) yes I have received some emails today. I have missed several emails for the past three days at least so thank you for confirming that the gmail outage was the issue. Much appreciated!


Tags: bitbucket-cloud

cloud
Repository Size Warning, but wrong size
Asked by philister:

Hi, we got that

```
remote: WARNING Repository size in Bitbucket is currently 1.9 GB
remote: Above the 2 GB size limit further commits are rejected
remote: Reduce repository size by removing large files from history
remote: HINT Learn how to reduce repository size: https://confluence.atlassian.com/x/xgMvEw
```

But git count-objects says

```
$ git count-objects -v
count: 3980
size: 22040
in-pack: 270784
packs: 27
size-pack: 1021295
prune-packable: 172
garbage: 0
size-garbage: 0

```

From what I read, we need that kind of GC?

The repo is: /pictrsgmbh/pictrs/

Thanks and regards, Phil


Answers:
author: Theodora Boudale
body: Hi Phil,

I ran a git gc for this repo and its size is now 986.6 MB.

Please feel free to let me know if things are ok now and if you need anything further!

Kind regards,  
Theodora

comments: author: philister
body: thx!


author: philister
body: Hi Theodora,

How about a "run GC"-button next to the repo size?

Best regards,  
Phil


author: Theodora Boudale
body: Hi Phil,

I understand that this would be useful, we have a feature request about this in our issue tracker:

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

I would suggest that you add your vote in that ticket (by selecting the **Vote for this issue** link) as the number of votes helps the development team and product managers better understand the demand for new features. You are more than welcome to leave any feedback, 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.

Implementation of new features is done as per our policy here <https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html> and any updates are posted in the feature request.

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

Kind regards,  
Theodora


author: Itamar Silva
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) I have the same Issue I am unable to push my changes   
because it exceded 2GB can you please help me on it   
This is the repository: <https://bitbucket.org/backendpag/pag-ios/src>   
Thanks


Tags: bitbucket-cloud

cloud
Emojis in readme
Asked by theng:

Hello,

I want to display a "?" readme.md.

```
Atlassian Bitbucket v7.6.1
```

I am very aware of the double colon shortcut (e.g. ":seedling:" for "?") but I don't want to use this.

I am using utf8 file for READMEs and inside I just put a plain emoji.

When I open my README.md in raw inside bitbucket I see the "?" but when it's displayed by BitBucket I see :

```
????
```

There is some emojis that work. For example these ones are displayed as expected:

```
?
?
?
```

Is this normal ?

Regards


Answers:
author: Rafael Parmigiani
body: Hi Theng,

I'm not sure whether you are still facing this problem, but what you have reported here was in fact a bug that affected multiple Bitbucket versions, including the one you were running at the time this question was posted.

Should you still be running on version **7.6.1** and as a future reference for others that might come across the same question, here is the original bug report:

[BSERV-10663 - Unicode emojis are garbled in markdown rendered view](https://jira.atlassian.com/browse/BSERV-10663)

It's been fixed on version **7.12**?.


Tags: bitbucket-server

emoji

readme

server

utf
Python application with socket in Pipelines
Asked by Roberto-R:

I am developing an application that uses the \`sockets\` package. I included \`unittest\` unit tests to test the application.

The complete *bitbucket-pipelines.yml*:

```
image: python:3.8
pipelines:
default:
- step:
script:
- pip install --upgrade pip
- pip install --upgrade sockets coverage
- git submodule update --init
- python -m coverage run -m unittest discover
- bash <(curl -s https://codecov.io/bash)
```

However, the pipeline throws errors when the unit tests are being performed:

    + python -m coverage run -m unittest discover
    ..........................EException in thread Serial server thread:
    Traceback (most recent call last):
    File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
    File "/opt/atlassian/pipelines/agent/build/uart3br/_serial_server.py", line 50, in run
    self.socket.bind((self.HOST, self.PORT))
    OSError: [Errno 98] Address already in use

    # ...

The complete pipe (and source): <https://bitbucket.org/ctw-bw/micropython-dummy-modules/addon/pipelines/home#!/results/6>

Of course the tests pass without problems on my computer (Windows 10, Python 3.8).

The socket creation looks like:

```
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Set option to allow instant socket reuse after shutdown
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

self.socket.bind(('127.0.0.1', 52184))

self.socket.listen()

# ...
```

The error trace is a little hard to follow, but two different errors are being throws:

    OSError: [Errno 98] Address already in use

and

```
ConnectionRefusedError: [Errno 111] Connection refused
```

I was wondering if other people have had experience with this and what could be the solution to this problem.


Answers:
author: Roberto-R
body: Figured it out.

I tested the pipeline [locally with Docker](https://support.atlassian.com/bitbucket-cloud/docs/debug-pipelines-locally-with-docker/), where I ran into the same errors. Apparently there is something with the Python image / Debian / Docker (or a combination) that does not allow rapid opening and closing of sockets.

Instead I restructured my tests to only open and close the server socket once (using \`setUpClass()\` instead of \`setUp()\`).

Working pipeline: <https://bitbucket.org/ctw-bw/micropython-dummy-modules/addon/pipelines/home#!/results/9>

So there is nothing keeping sockets from working.


Tags: atl-pipelines

bitbucket-cloud

bitbucket-pipelines

cloud

python

socket

test
How to remove old Bitbucket server versions after an upgrade
Asked by David Pati?o:

Hello,

We've been performed many bitbucket upgrades during last years. Now we need to get free space in the server removing no needed older versions. How could we remove old Bitbucket server versions after an upgrade? What are the paths to remove? In linux server is it manually?

Thanks a lot.

Kind Regards,


Answers:
author: Nic Brough -Adaptavist-
body: It depends on how you have been doing the upgrades.

A standard upgrade process will create a new bitbucket installation directory and reuse the data (home) directory, so I would expect to see a batch of old install directories that you are no longer using. You can simply delete these entirely.

If you've been doing it in other ways, or taking backup copies, then we can't tell you anything more than "delete the stuff you're not using"

comments: author: David Pati?o
body: Hi,

Standard upgrade, installation directory in /opt/atlassian/bitbucket/x.x.x

So I guess directly remove (rm -rf) each x.x.x older version, isn't it?

Thnask a lot.

Kind Regards,


author: Jimmy Seddon
body: I can't be 100% sure but that sounds like what I did on our Windows server to clean up old versions.


author: Nic Brough -Adaptavist-
body: Sorry for the delay, but yes, exctly that!


Tags: bitbucket-server

server
Users need to sign in to view a repo! (Don't want!)
Asked by SnailDOS:

Recently, I published a PUBLIC REPO, so people can view, however, I disabled sign up, it's meant to be view only. After some time, I noticed that no one can access anything on my Bitbucket server, because you need to sign in to view a repo!

How can I disable this?

Regards,

SnailDOS


Answers:
author: SnailDOS
body: In the repo config, You can enable it public, just found out.

Thanks all.


Tags: bitbucket-server

login

repository

server

view