提交 9aad5ed0 编写于 作者: J Jeff Brown

Fixes Microsoft Teams notifications for pipeline events

Closes #42342
上级 54a6ca6f
...@@ -26,13 +26,18 @@ module ChatMessage ...@@ -26,13 +26,18 @@ module ChatMessage
end end
end end
def pretext def summary
return message if markdown return message if markdown
format(message) format(message)
end end
def pretext
summary
end
def fallback def fallback
format(message)
end end
def attachments def attachments
......
...@@ -23,10 +23,6 @@ module ChatMessage ...@@ -23,10 +23,6 @@ module ChatMessage
'' ''
end end
def fallback
format(message)
end
def attachments def attachments
return message if markdown return message if markdown
......
...@@ -44,7 +44,7 @@ class MicrosoftTeamsService < ChatNotificationService ...@@ -44,7 +44,7 @@ class MicrosoftTeamsService < ChatNotificationService
def notify(message, opts) def notify(message, opts)
MicrosoftTeams::Notifier.new(webhook).ping( MicrosoftTeams::Notifier.new(webhook).ping(
title: message.project_name, title: message.project_name,
pretext: message.pretext, summary: message.summary,
activity: message.activity, activity: message.activity,
attachments: message.attachments attachments: message.attachments
) )
......
---
title: Fixes Microsoft Teams notifications for pipeline events
merge_request: 19632
author: Jeff Brown
type: fixed
...@@ -30,7 +30,7 @@ module MicrosoftTeams ...@@ -30,7 +30,7 @@ module MicrosoftTeams
result = { 'sections' => [] } result = { 'sections' => [] }
result['title'] = options[:title] result['title'] = options[:title]
result['summary'] = options[:pretext] result['summary'] = options[:summary]
result['sections'] << MicrosoftTeams::Activity.new(options[:activity]).prepare result['sections'] << MicrosoftTeams::Activity.new(options[:activity]).prepare
attachments = options[:attachments] attachments = options[:attachments]
......
...@@ -8,7 +8,7 @@ describe MicrosoftTeams::Notifier do ...@@ -8,7 +8,7 @@ describe MicrosoftTeams::Notifier do
let(:options) do let(:options) do
{ {
title: 'JohnDoe4/project2', title: 'JohnDoe4/project2',
pretext: '[[JohnDoe4/project2](http://localhost/namespace2/gitlabhq)] Issue [#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1) opened by user6', summary: '[[JohnDoe4/project2](http://localhost/namespace2/gitlabhq)] Issue [#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1) opened by user6',
activity: { activity: {
title: 'Issue opened by user6', title: 'Issue opened by user6',
subtitle: 'in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)', subtitle: 'in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)',
......
...@@ -225,10 +225,15 @@ describe MicrosoftTeamsService do ...@@ -225,10 +225,15 @@ describe MicrosoftTeamsService do
it 'calls Microsoft Teams API for pipeline events' do it 'calls Microsoft Teams API for pipeline events' do
data = Gitlab::DataBuilder::Pipeline.build(pipeline) data = Gitlab::DataBuilder::Pipeline.build(pipeline)
data[:markdown] = true
chat_service.execute(data) chat_service.execute(data)
expect(WebMock).to have_requested(:post, webhook_url).once message = ChatMessage::PipelineMessage.new(data)
expect(WebMock).to have_requested(:post, webhook_url)
.with(body: hash_including({ summary: message.summary }))
.once
end end
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册