gocd-contrib/email-notifier

Not showing job failure in stage

Opened this issue · 1 comments

Hello!

This is likely not implemented but I wanted to check/suggest.

The notification seems to only reflect the status of a stage. Is it possible to pull in the job(s) that caused the stage to fail? We're trying to track/alert on job failures based on frequency. I couldn't tell if this was just a change in the filter or if that is a major change to the plugin code.

Thanks!

I believe it's technically possible via the plugin API (the plugin receives https://plugin-api.gocd.org/current/notifications/#stage-completion-notifications) however the plugin needs work to do this.

String body = String.format("State: %s\nResult: %s\nCreate Time: %s\nLast Transition Time: %s", stageState, stageMap.get("result"), stageMap.get("create-time"), stageMap.get("last-transition-time"));

Not that difficult, but this plugin appears to be an extremely simple implementation of the API, and a little bit hacky (it does not model the structure of the notifications fully, it just accesses dictionary-of-dictionaries which is pretty clunky in Java). The filter only affects which pipelines/stages are notified upon; not the content.

If your goal is to do something more sophisticated around alerting/monitoring, I'm not sure basing it on this very simple plugin (and/or the content of an email it sends) is the best idea. You might be better to write something directly against the GoCD API where you will get all the information you need as structured JSON.