Running BB Hooks as a different account

Hook that sends notifications via email. If the email goes to a user that is no longer at the company, the bounces go to both the “from” address as well as the “Atlassian” account under which BB runs.

Question is can we change the sender so that bounces go nowhere / null? Can the hook script be run as a different user than the owner of the BB process?

Hi @marlang

I’m a developer with the Bitbucket Server team.

Could you provide a bit more context as to how the plugin works? Is it implementing one of our Hook SPI interfaces? If so, which one?

Which API are you using to send the email? Our MailService/SoyMailBuilder APIs should allow you to set the from address. In terms of the user running the hook, you can use the SecurityService API to execute some code while impersonating a user.

If you describe in a bit more details the way the plugin works we may be able to give you some guidance on how to achieve your goal. If you feel you can share this information in a public forum please feel free to create a support ticket at: https://getsupport.atlassian.com/

Regards
Juan Palacios
Atlassian - Bitbucket Server

Thanks! So i’ll get someone who knows the ins and outs a bit better than me to reply or open a support ticket.

What I know about the hook is that it is a pre receive hook that pulls some settings values from the plugin, pulls in some of the repo settings and is wrapped around some code that sends the values out to a perl script (because this perl script is use by our raw git service, github, bitbucket, and gerrit services, since we have to support all of them).

The perl script makes sure the commit message provides a valid rally ID, attaches the diff, and emails the user or group of users that are part of the settings if the commit passes or fails and why.

So i’d like to run all the code for the pre-receive or at least the code that calls out to the perl script as a non admin account so that if there are users getting emailed that are no longer at the company, it doesn’t bounce back to the admin account, it bounces back to the generic account or the person doing the commit (which would be better).

Does this make sense?

Hi @marlang
Thank you for providing those details. I don’t think that Bitbucket Server can execute a perl command as a delegated user. If the command is running as an admin account it’s because Bitbucket Server is running as an administrator account which is not advisable. Our installer sets up a dedicated account (atlbitbucket) with the required level of permission for the system to run correctly.

Is it possible for you to setup the system to run under a different account? If you need assistance with this I’d encourage you to raise a support ticket at: https://getsupport.atlassian.com/

Alternatively you could code the Perl script to setup a “from” header for the user who should receive the email if it bounces back.

Hope you found the information useful.

Regards
Juan Palacios