Merge branch '42342-teams-pipeline-notifications' into 'master'
Resolve "Microsoft Teams notification for pipelines do not work" Closes #42342 See merge request gitlab-org/gitlab-ce!19632
This commit is contained in:
commit
504f362033
|
@ -26,13 +26,18 @@ module ChatMessage
|
|||
end
|
||||
end
|
||||
|
||||
def pretext
|
||||
def summary
|
||||
return message if markdown
|
||||
|
||||
format(message)
|
||||
end
|
||||
|
||||
def pretext
|
||||
summary
|
||||
end
|
||||
|
||||
def fallback
|
||||
format(message)
|
||||
end
|
||||
|
||||
def attachments
|
||||
|
|
|
@ -23,10 +23,6 @@ module ChatMessage
|
|||
''
|
||||
end
|
||||
|
||||
def fallback
|
||||
format(message)
|
||||
end
|
||||
|
||||
def attachments
|
||||
return message if markdown
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class MicrosoftTeamsService < ChatNotificationService
|
|||
def notify(message, opts)
|
||||
MicrosoftTeams::Notifier.new(webhook).ping(
|
||||
title: message.project_name,
|
||||
pretext: message.pretext,
|
||||
summary: message.summary,
|
||||
activity: message.activity,
|
||||
attachments: message.attachments
|
||||
)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fixes Microsoft Teams notifications for pipeline events
|
||||
merge_request: 19632
|
||||
author: Jeff Brown
|
||||
type: fixed
|
|
@ -30,7 +30,7 @@ module MicrosoftTeams
|
|||
result = { 'sections' => [] }
|
||||
|
||||
result['title'] = options[:title]
|
||||
result['summary'] = options[:pretext]
|
||||
result['summary'] = options[:summary]
|
||||
result['sections'] << MicrosoftTeams::Activity.new(options[:activity]).prepare
|
||||
|
||||
attachments = options[:attachments]
|
||||
|
|
|
@ -8,7 +8,7 @@ describe MicrosoftTeams::Notifier do
|
|||
let(:options) do
|
||||
{
|
||||
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: {
|
||||
title: 'Issue opened by user6',
|
||||
subtitle: 'in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)',
|
||||
|
|
|
@ -225,10 +225,15 @@ describe MicrosoftTeamsService do
|
|||
|
||||
it 'calls Microsoft Teams API for pipeline events' do
|
||||
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
|
||||
data[:markdown] = true
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue