class Octobot::SlackAgent::DeployNotifier
Attributes
gerrit_url[RW]
gitblit_url[RW]
Public Class Methods
new(gitblit_url, gerrit_url, webhook_url, username='octobot', icon_emoji=nil)
click to toggle source
Calls superclass method
# File lib/octobot/slack_agent/deploy_notifier.rb, line 8 def initialize(gitblit_url, gerrit_url, webhook_url, username='octobot', icon_emoji=nil) @gitblit_url = gitblit_url @gerrit_url = gerrit_url super webhook_url, username, icon_emoji end
Public Instance Methods
deployed(app, environment, git_hash, commit_msg, author, deployer)
click to toggle source
# File lib/octobot/slack_agent/deploy_notifier.rb, line 14 def deployed(app, environment, git_hash, commit_msg, author, deployer) title, message = process_message commit_msg send_attachments [ attachment({ pretext: "#{app} #{environment} has been updated to #{git_hash}", title: title, title_link: gitblit_link(app, git_hash), text: message, fields: [ { title: "Author", value: author, short: false }, { title: "Deployer", value: deployer, short: false } ] }, 'good') ] end
Private Instance Methods
gitblit_link(app, git_hash)
click to toggle source
# File lib/octobot/slack_agent/deploy_notifier.rb, line 40 def gitblit_link(app, git_hash) "#{gitblit_url}/commit/?r=#{app}&h=#{git_hash}" end
process_message(commit_msg)
click to toggle source
# File lib/octobot/slack_agent/deploy_notifier.rb, line 44 def process_message(commit_msg) message_ar = commit_msg.split("\n") title = message_ar.shift message = message_ar.join("\n") message.gsub!(/Change-Id: (I[a-f0-9]+)/, "Change-id: <#{gerrit_url}/#/q/\\1|\\1>") [title, message] end