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 do I send emaijl notifications to email groups only on build failure?

Edited

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

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.

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. 

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.

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

Like Matias_Bjarland likes this

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
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 their  Jira Cloud instance.  ...

489 views 16 17
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