diff --git a/app/lib/actions/katello/content_view/promote.rb b/app/lib/actions/katello/content_view/promote.rb index 83d327bbe17..e15df02f9f2 100644 --- a/app/lib/actions/katello/content_view/promote.rb +++ b/app/lib/actions/katello/content_view/promote.rb @@ -4,6 +4,7 @@ module ContentView class Promote < Actions::EntryAction extend ApipieDSL::Class include ::Actions::ObservableAction + execution_plan_hooks.use :notify_on_failure, :on => :failure def plan(version, environments, is_force = false, description = nil, incremental_update = false) action_subject(version.content_view) @@ -23,6 +24,14 @@ def plan(version, environments, is_force = false, description = nil, incremental end end + def notify_on_failure(_plan) + notification = MailNotification[:cv_promote_failure] + view = ::Katello::ContentView.find(input.fetch(:content_view, {})[:id]) + notification.users.each do |user| + notification.deliver(user: user, content_view: view, task: task) + end + end + def environments input['environments'] end diff --git a/app/mailers/katello/task_mailer.rb b/app/mailers/katello/task_mailer.rb index c19dd0fed6f..fc1bb27fd17 100644 --- a/app/mailers/katello/task_mailer.rb +++ b/app/mailers/katello/task_mailer.rb @@ -26,5 +26,17 @@ def cv_publish_failure(options) end end end + + def cv_promote_failure(options) + user, @content_view, @task = options.values_at(:user, :content_view, :task) + + ::User.as(user.login) do + subject = _("%{label} failed") % { :label => @task.action } + + set_locale_for(user) do + mail(:to => user.mail, :subject => subject) + end + end + end end end diff --git a/app/views/katello/task_mailer/cv_promote_failure.html.erb b/app/views/katello/task_mailer/cv_promote_failure.html.erb new file mode 100644 index 00000000000..48dce54339a --- /dev/null +++ b/app/views/katello/task_mailer/cv_promote_failure.html.erb @@ -0,0 +1,31 @@ +
+ <%= _("%{label} failed.") % { :label => @task.action } %> +
+ +<%= _('Content view') %> | +<%= link_to @content_view.name, "#{katello_url}content_views/#{@content_view.id}" %> | +
<%= _('Task ID') %> | +<%= link_to @task.id, foreman_tasks_task_url(@task.id) %> | +
<%= _('Task state') %> | +<%= @task.state %> | +
<%= _('Task result') %> | +<%= @task.result %> | +