phallstrom / slackistrano

Slack integration for Capistrano deployments.
MIT License
374 stars 74 forks source link

Added support for fields and fallback in the attachments. #29

Closed fernandocarletti closed 9 years ago

phallstrom commented 9 years ago

@xurumelous Can I trouble you to save me a bit of research and quickly explain what fields/fallback are for? What's the reason for them? Thx!

fernandocarletti commented 9 years ago

Of course. The fields is used for adding more "rich" data to the message, ass this example:

Sample

In this case, Project and Environmentare two different fields, and ReferenceError - UI is not defined is the text of the message.

The fallback, allows you to display a simple text message where the "rich" data can't be displayed (e.g. notifications).

More info: https://api.slack.com/docs/attachments

phallstrom commented 9 years ago

Ah. Slick. So fields are 'Project' and "Environment'? Would you mind adding a bit to to the readme to explain this (if you want to embed that screenshot, that's cool too). Could see a lot of folks wanting to adopt it.

fernandocarletti commented 9 years ago

I was thinking about to put my format as default, but it would break backward compatibility. I can share my config later, but it still need some improvements (right now it is really specific about my company).

This is what I have so far:

Mine

phallstrom commented 9 years ago

Yeah, I've had three formatting PR's in the last week. I think I'd prefer to leave the default alone to avoid a format war, but a section in the README (or maybe I should open up the wiki) on custom formats would be nice. README or wiki? Thoughts?

fernandocarletti commented 9 years ago

We would have to define what information we want to display. The links, I am getting in a dumb way right now, It would have to be improved in order to get it abstract enough for having it as standard.

About the format war, since the fields are highly customizable, we should define a default format and let the user change the way they want.

My current configuration is this:

set :slack_fallback_finished, "#{fetch(:slack_deploy_user)} deployed #{fetch(:application)} on #{fetch(:stage)}"
set :slack_fields_finished, [
  {
    "title": "Project",
    "value": "<https://github.com/XXXXXXX/#{fetch(:application)}|#{fetch(:application)}>",
    "short": true
  },
  {
    "title": "Environment",
    "value": fetch(:stage),
    "short": true
  },
  {
    "title": "Deployer",
    "value": fetch(:slack_deploy_user),
    "short": true
  },
  {
    "title": "Revision",
    "value": "<https://github.com/XXXXXXX/#{fetch(:application)}/commit/#{fetch(:slack_revision)}|#{fetch(:slack_revision)[0..6]}>",
    "short": true
  }
]

Since the variables are already there, it is a matter of disabling the msg and putting the fields and fallback in action. Who needs it different, customize it.

I'll add this in the README.md for now.

fernandocarletti commented 9 years ago

@phallstrom I added more information to the README.md.

phallstrom commented 9 years ago

Thanks @xurumelous! I've pushed 0.1.12 to rubygems.