-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send commit log between 2 deployments. #50
Comments
Maybe. I have grand visions of re-working the messaging sent to Slack to make it easier for folks to do this sort of thing themselves. I don't want to get into a situation of having more settings than we already have if I can help it. Do you really want the log output? That could be a ton of information... just curious. |
Yes It could be really helpfull for us. We deploy everyday, so logs between deploy are small, and it will help teams on slack to understand what has been sent to production. You're right, it should be an option for teams who deploy every month (log is useless in this case). I can probably already get it by myself with a ruby function in capistrano and send the output to the message sent via slackistrano, I post the issue because I thought it could make sense in slakistrano config (commit_log => true/false). Thanks ! |
@pierrerigal Assuming you've got the two revisions, what is the git command you run to generate the commit log? |
Very basic log would look like: git log --oneline <new revision hash>..<old revision hash> |
I have no idea is it still relevant, but I've solved this as following. module Capistrano
class My < ::Capistrano::SCM::Plugin
def define_tasks
eval_rakefile File.expand_path("../tasks/my.rake", __FILE__)
end
def register_hooks
after "deploy:published", "My:set_changelog"
end
end In desc "Get changelog between releases"
task :set_changelog do
on release_roles(:all) do
set(:changelog, capture(:diff,
'--unchanged-line-format=""',
'--new-line-format="%L"',
'--text',
File.join(fetch(:release_path), "CHANGELOG"),
File.join(fetch(:previous_release_path), "CHANGELOG"),
"2>/dev/null; true" # diff exits with 1 if there is a difference found
).force_encoding(Encoding::UTF_8))
end
end In def payload_for_updated
{
attachments: [{
color: 'good',
title: 'My Backend deployment finished',
fields: [{
title: 'Environment',
value: stage,
short: true
}, {
title: 'Branch',
value: branch,
short: true
},{
title: 'Deployed revision',
value: fetch(:current_revision),
short: true
}, {
title: 'Previous revision',
value: fetch(:previous_revision),
short: true
}, {
title: 'Deployer',
value: deployer,
short: true
}, {
title: 'Time',
value: elapsed_time,
short: true
}, {
title: 'Changelog',
value: fetch(:changelog).gsub(/\(#(\d+)\)/, "(<%{repo_url}/pull/%{pr}|#%{pr}>)" % {repo_url: fetch(:repo_url), pr: '\1'})
}],
footer: "<#{fetch(:repo_url)}/compare/#{fetch(:previous_revision)}...#{fetch(:current_revision)}|See the diff on github.com>",
footer_icon: "https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png",
fallback: super[:text]
}]
}
end The regexp you can see in Changelog value will substitute Github pullrequest numbers withing links to related pullrequest on Github (if |
Is this something that can be picked up? Notifying in Slack is extremely useful when someone does not have access to the repo. Thus actually showing the |
@martijnhartlief Absolutely! If you want to work on this and submit a PR that would be great. I would encourage you to do it as a custom messaging class people can leverage instead of building it in directly. I can bring the code in, but it keeps it a bit more isolated. |
Thanks! How and where did set |
@dapi I added custom task after built-in step named def register_hooks
after "deploy:set_previous_revision", "My:set_previous_release_path"
end namespace :My do
desc "Set previous release path"
task :set_previous_release_path do
on release_roles(:all) do
if test("[ -d #{release_path} ]")
set(:previous_release_path, capture(:readlink, release_path))
else
warn "There is no previous release directory found, maybe the first deployment"
set(:previous_release_path, release_path)
end
info "Previous release path: #{fetch(:previous_release_path)}"
end
end
end |
Hello,
Could you include the commit history log in the slack output between 2 revisions to help developers (and non developpers on channels) to understand what has been sent with each deploy.
You can find previous revision number in {current_path}/REVISION file in capistrano.
Thx !
The text was updated successfully, but these errors were encountered: