Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I send emaijl notifications to email groups only on build failure?

Matias_Bjarland June 3, 2020

I'm using bitbucket pipelines and the email-notify plugin at: 

 

https://bitbucket.org/atlassian/email-notify/src/master/

 

I have this working in a bitbucket pipeline as far as it goes. The intent here is to send emails to a mailing list/group/alias and not just the committer.

The documentation is however very quiet about a number of things. For example: when are emails sent? every build? build success? build failure? Only on state (fail/success) changes? How do we control this? Where is that documented?

I thought it only sent on build failure but that does not seem to be true. Also it would be very helpful if it was possible to send the same email content as is sent with the existing build failure email to the committer. 

It would also be useful to have the build log available as an environment variable, a file, or really anything which it would be possible to include in the email. I realize we can do this by using redirection on the pipelines step script shell so this is not really a blocker, more of a usability issue.

In essence, we have a isolated email pipe without any way of integrating it to the build state (preferably only send emails on state change), the build log, the already styled and generated emails which are sent by bitbucket etc. I think this integration could use some more work. 

If I had to choose one question I guess it would be: How do I send emails only on build failure? 

1 answer

0 votes
Radek Antoniuk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2020

What's wrong with using built-in e-mail notifications for the repository?

What you are using is a custom-pipe, so it will send emails whenever your pipeline definition step is executed according to your YAML definition file.

Matias_Bjarland June 3, 2020

That is true, but I have not been able to figure out a way to send those notifications to an email group/alias/list. This pipeline is run in an enterprise context where it is not enough to send the email to the committer and we need a way to control who gets the email. 

If there is a way to configure the normal notifications to be sent to an email group then that would work as a solution to this. 

Radek Antoniuk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2020

Got it, I don't think it's currently possible, I'm using Slack notification for failed builds in such cases.

The  condition would be perfect for this, however it is not supporting it at the moment according to documentation.

Maybe one of the maintainers of the email-notify pipe will see this and add an ENABLED flag to the pipe, but I don't see even a variable that could be used for controlling this.

Alternatively... you could create your own pipe, basing on the official email-notify one and extend it somehow to run conditionally.

Radek Antoniuk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2020

Oh, I stand corrected, here's a complete example how to do it!

Like Matias_Bjarland likes this
Matias_Bjarland June 4, 2020

Mind posting that as an answer and I'll mark it as accepted? That is perfect for my needs and solves my problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events