Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0f8d4ab7
Commit
0f8d4ab7
authored
Mar 29, 2020
by
Balasankar "Balu" C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show only actually failed CI jobs in notifications
Signed-off-by:
Balasankar "Balu" C
<
balasankarc@autistici.org
>
parent
6c39d8d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
1 deletion
+70
-1
app/models/project_services/chat_message/pipeline_message.rb
app/models/project_services/chat_message/pipeline_message.rb
+14
-1
changelogs/unreleased/slack-notification-retry-success-skip.yml
...logs/unreleased/slack-notification-retry-success-skip.yml
+5
-0
spec/models/project_services/chat_message/pipeline_message_spec.rb
...ls/project_services/chat_message/pipeline_message_spec.rb
+51
-0
No files found.
app/models/project_services/chat_message/pipeline_message.rb
View file @
0f8d4ab7
...
@@ -34,7 +34,9 @@ module ChatMessage
...
@@ -34,7 +34,9 @@ module ChatMessage
@duration
=
pipeline_attributes
[
:duration
].
to_i
@duration
=
pipeline_attributes
[
:duration
].
to_i
@finished_at
=
pipeline_attributes
[
:finished_at
]
?
Time
.
parse
(
pipeline_attributes
[
:finished_at
]).
to_i
:
nil
@finished_at
=
pipeline_attributes
[
:finished_at
]
?
Time
.
parse
(
pipeline_attributes
[
:finished_at
]).
to_i
:
nil
@pipeline_id
=
pipeline_attributes
[
:id
]
@pipeline_id
=
pipeline_attributes
[
:id
]
@failed_jobs
=
Array
(
data
[
:builds
]).
select
{
|
b
|
b
[
:status
]
==
'failed'
}.
reverse
# Show failed jobs from oldest to newest
# Get list of jobs that have actually failed (after exhausting all retries)
@failed_jobs
=
actually_failed_jobs
(
Array
(
data
[
:builds
]))
@failed_stages
=
@failed_jobs
.
map
{
|
j
|
j
[
:stage
]
}.
uniq
@failed_stages
=
@failed_jobs
.
map
{
|
j
|
j
[
:stage
]
}.
uniq
@project
=
Project
.
find
(
data
[
:project
][
:id
])
@project
=
Project
.
find
(
data
[
:project
][
:id
])
...
@@ -90,6 +92,17 @@ module ChatMessage
...
@@ -90,6 +92,17 @@ module ChatMessage
private
private
def
actually_failed_jobs
(
builds
)
succeeded_job_names
=
builds
.
map
{
|
b
|
b
[
:name
]
if
b
[
:status
]
==
'success'
}.
compact
.
uniq
failed_jobs
=
builds
.
select
do
|
build
|
# Select jobs which doesn't have a successful retry
build
[
:status
]
==
'failed'
&&
!
succeeded_job_names
.
include?
(
build
[
:name
])
end
failed_jobs
.
uniq
{
|
job
|
job
[
:name
]
}.
reverse
end
def
fancy_notifications?
def
fancy_notifications?
Feature
.
enabled?
(
:fancy_pipeline_slack_notifications
,
default_enabled:
true
)
Feature
.
enabled?
(
:fancy_pipeline_slack_notifications
,
default_enabled:
true
)
end
end
...
...
changelogs/unreleased/slack-notification-retry-success-skip.yml
0 → 100644
View file @
0f8d4ab7
---
title
:
Make pipeline info in chat notifications concise
merge_request
:
28284
author
:
type
:
changed
spec/models/project_services/chat_message/pipeline_message_spec.rb
View file @
0f8d4ab7
...
@@ -431,6 +431,57 @@ describe ChatMessage::PipelineMessage do
...
@@ -431,6 +431,57 @@ describe ChatMessage::PipelineMessage do
end
end
end
end
context
"when jobs succeed on retries"
do
before
do
args
[
:builds
]
=
[
{
id:
1
,
name:
"job-1"
,
status:
"failed"
,
stage:
"stage-1"
},
{
id:
2
,
name:
"job-2"
,
status:
"failed"
,
stage:
"stage-2"
},
{
id:
3
,
name:
"job-3"
,
status:
"failed"
,
stage:
"stage-3"
},
{
id:
7
,
name:
"job-1"
,
status:
"failed"
,
stage:
"stage-1"
},
{
id:
8
,
name:
"job-1"
,
status:
"success"
,
stage:
"stage-1"
}
]
end
it
"do not return a job which succeeded on retry"
do
expected_jobs
=
[
"<http://example.gitlab.com/-/jobs/3|job-3>"
,
"<http://example.gitlab.com/-/jobs/2|job-2>"
]
expect
(
subject
.
attachments
.
first
[
:fields
][
3
]).
to
eq
(
title:
"Failed jobs"
,
value:
expected_jobs
.
join
(
", "
),
short:
true
)
end
end
context
"when jobs failed even on retries"
do
before
do
args
[
:builds
]
=
[
{
id:
1
,
name:
"job-1"
,
status:
"failed"
,
stage:
"stage-1"
},
{
id:
2
,
name:
"job-2"
,
status:
"failed"
,
stage:
"stage-2"
},
{
id:
3
,
name:
"job-3"
,
status:
"failed"
,
stage:
"stage-3"
},
{
id:
7
,
name:
"job-1"
,
status:
"failed"
,
stage:
"stage-1"
},
{
id:
8
,
name:
"job-1"
,
status:
"failed"
,
stage:
"stage-1"
}
]
end
it
"returns only first instance of the failed job"
do
expected_jobs
=
[
"<http://example.gitlab.com/-/jobs/3|job-3>"
,
"<http://example.gitlab.com/-/jobs/2|job-2>"
,
"<http://example.gitlab.com/-/jobs/1|job-1>"
]
expect
(
subject
.
attachments
.
first
[
:fields
][
3
]).
to
eq
(
title:
"Failed jobs"
,
value:
expected_jobs
.
join
(
", "
),
short:
true
)
end
end
context
"when the CI config file contains a YAML error"
do
context
"when the CI config file contains a YAML error"
do
let
(
:has_yaml_errors
)
{
true
}
let
(
:has_yaml_errors
)
{
true
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment