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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.