phallstrom / slackistrano

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

Add version to the message #58

Closed halida closed 7 years ago

halida commented 7 years ago

Is there any way to add git version to the deploy message? so we will know which version is deployed.

phallstrom commented 7 years ago

Do you mean like the git sha or a tag or?

halida commented 7 years ago

@phallstrom Yes. I read the source code, looks like slackistrano runs on the local, the only way to get version is from remote server, like Airbrake, it runs on the server: https://github.com/airbrake/airbrake/blob/master/lib/airbrake/capistrano/tasks.rb#L10

phallstrom commented 7 years ago

Ok. I think that is going to be the "date string" capistrano uses. Do you want that or do you want the most recent git sha or something else?

halida commented 7 years ago

@phallstrom Use git sha is accurate. So we can know which version is deployed.

halida commented 7 years ago

@phallstrom As you can see the link above, Airbrake implement deploy notification by add an rake task, then trigger it on the server side, so it can fetch git sha and log it. you may consider this method.

phallstrom commented 7 years ago

Probably the best thing is to make your own custom messenger class and add something like this (or whatever works from your local machine to get the right value)

`git rev-parse origin/#{fetch(:branch)}`.strip!

See https://github.com/phallstrom/slackistrano#customizing-the-messaging

halida commented 7 years ago

@phallstrom Yes, this is an good idea. maybe you can update helper.rb to add this? Also, I really think make this as default is a good idea:

    def payload_for_updated
      {attachments: [
         {color: 'good',
          title: "[#{application}] Deployed",
          fields: [
            {title: 'Environment',
             value: stage,
             short: true
            },
            {title: 'Branch',
             value: branch,
             short: true
            },
            {title: 'Deployer',
             value: deployer,
             short: true
            },
            {title: 'Time',
             value: elapsed_time,
             short: true
            },
            {title: 'Version',
             value: `git rev-parse origin/#{branch}`.strip!,
             short: false,
            }
          ],
          fallback: super[:text],
         }]
      }
    end
halida commented 7 years ago

@phallstrom Also, run this code may not accurate, local origin cache may not sync with remote origin.

phallstrom commented 7 years ago

If you can figure out how to utilize Capistrano's SCM class to get this information generically I'd be willing to add it. I don't want to add the above as it's Git specific and not everyone uses it. However, the above is exactly why I broke out the ability to set a custom messaging class so you can do this sort of thing locally.