Automatic email notifications to the author of a broken commit



I want my collaborators to get a “you broke the build” notification if they push a breaking change. But unfortunately, most of them haven’t ever logged into CircleCI themselves, much less configured their notification settings.

OK, yeah, I could ask all of my collaborators to please “follow” the project in CircleCI, but then they’d get also spammed with notifications any time someone else breaks the build. (Right?) I’d like only the naughty committer to get the emails, no one else (well, except for people who’ve explicitly subscribed to all notifications).

FWIW, Travis-CI has the desired behavior by default (despite being inferior in other ways…). If CircleCI already has this feature, then just tell me I’m dumb. (And then tell me how to activate it!)


We currently can’t do exactly that—however, one of the available email notification preferences is:

Send me a personalized email every time a build on a branch I’ve pushed to fails; also once they’re fixed.

When selecting this option, the person will only get email notifications for branches they pushed to in the past. Could that work for your team?

Another option could be to write a Slack bot that would ping the person who broke the build—for that you’ll have to use Slack API together with CircleCI webhooks.


Thanks for the advice!

When selecting this option, the person will only get email notifications
for branches they pushed to in the past. Could that work for your team?

That’s not quite what I’m looking for, but it’s a start. (I’m not a paying customer, so I don’t expect priority treatment.)

I posted this feature request because Sean recommended that I do so, to give others a chance to “like” it. I was somewhat surprised to learn that CircleCI doesn’t support this notification setup, since it seems desirable for most open source teams, and Travis-CI supports it by default.

Another option could be to write a Slack bot

I don’t use Slack, so I guess this isn’t an option for me.


I’m thinking a test-post hook might do the trick, something that checks if the build failed and then mails the commit author.

You can get the commit author’s email with git log HEAD^..HEAD --pretty='%aN <%aE>' | sort -u

I’m using .mailmap to handle GitHub’s fake emails

I’m running into a stumbling block trying to figure out how to tell if a build passes or fails in a test-agnostic way though.

@alexey Does CircleCi have a test status env? I didn’t see one.


Unfortunately we don’t have a test status var, but you could potentially figure out if the tests passed or not by looking at the status of the test command:

    - test-command && echo "success" || echo "failure"

Alternatively, you could execute some commands in the “catch-all” deployment section—that one will only be run if all tests passed.


Deployment wouldn’t work, as I we want to catch failure.

Your first suggestion of chaining seems to fail as well, see Chaining fails if one task returns non-zero


Hope my explanation of chaining in the post you link to helps.


It does, thanks. However, despite all my learning on this project, it seems it’s near impossible to send email out of a CI box, due to missing software and possibly AWS just plain blocking it.

So I’m on board for this as a feature as well.


Maybe using AWS SES or a similar API-based email service could work for you in the meanwhile? HTTP API calls will not be blocked, plus you get higher deliverability out of the box.


+1. This is a key productivity feature that Jenkins/Hudson has supported for several years. Having this simple automation in place significantly increases the value of having CI since breakages are seen by the relevant developers more quickly. If somebody is forgetful about tests they will be reminded right away (without human intervention).


+1. Our main repository is not on GitHub, but we mirror it to GitHub to be able to use CircleCI (because it’s awesome). Unfortunately this means that all pushes to GitHub are done by our mirroring bot’s account (“Triggered by” on build page) and all notifications about broken builds go to the bot’s mail address. Sending the notifications to the commit’s author instead (which is already listed as “Author” on the build page) would solve it for us.


If the commiter is a CircleCI user, they will be autofollowed to the project (with an email letting them know “you pushed to this project so it’s a fair assumption you would want to get notifications, if you don’t unsub here”).
This solves the case if the commiter is a CircleCI user.

There’s no current fix if the commiter is not a CircleCI user but actively thinking about it! Feel free to make a different request just for that but we already understand it’s a popular request that we’d like to solve soon.


There’s also a related issue with notifications, which is that not every test notification (fix/failure) needs to be sent to everybody. If I’m working on my own branch that no-one else has pushed to, then I want to get email notifications, but nobody else needs them, and the Slack channel doesn’t need them either.


That email notification preference is good, but when you have committed to master you’ll be notified off all failures in the future :frowning: