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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get logged in users email when running pipeline

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 

1 answer

1 accepted

0 votes
Answer accepted

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:

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

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across Jira Cloud instance.   📢 Get y...

121 views 6 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you