-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(1572): [2] Add FIXED status to the build #30
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -17,6 +17,7 @@ const COLOR_MAP = { | |||||||
BLOCKED: '#ccc', // Using 'sd-light-gray' from https://github.com/screwdriver-cd/ui/blob/master/app/styles/screwdriver-colors.scss | ||||||||
UNSTABLE: '#ffd333', // Using 'sd-unstable' from https://github.com/screwdriver-cd/ui/blob/master/app/styles/screwdriver-colors.scss | ||||||||
COLLAPSED: '#f2f2f2', // New color. Light grey. | ||||||||
FIXED: 'good', | ||||||||
FROZEN: '#acd9ff' // Using 'sd-frozen' from https://github.com/screwdriver-cd/ui/blob/master/app/styles/screwdriver-colors.scss | ||||||||
}; | ||||||||
const STATUSES_MAP = { | ||||||||
|
@@ -29,6 +30,7 @@ const STATUSES_MAP = { | |||||||
BLOCKED: ':lock:', | ||||||||
UNSTABLE: ':foggy:', | ||||||||
COLLAPSED: ':arrow_up:', | ||||||||
FIXED: ':sunny:', | ||||||||
FROZEN: ':snowman:' | ||||||||
}; | ||||||||
const DEFAULT_STATUSES = ['FAILURE']; | ||||||||
|
@@ -68,7 +70,8 @@ const SCHEMA_BUILD_DATA = Joi.object() | |||||||
id: Joi.number().integer().required() | ||||||||
}).unknown(true), | ||||||||
event: Joi.object(), | ||||||||
buildLink: Joi.string() | ||||||||
buildLink: Joi.string(), | ||||||||
isFixed: Joi.boolean() | ||||||||
}); | ||||||||
const SCHEMA_SLACK_CONFIG = Joi.object() | ||||||||
.keys({ | ||||||||
|
@@ -136,6 +139,11 @@ class SlackNotifier extends NotificationBase { | |||||||
buildData.settings.slack.statuses = DEFAULT_STATUSES; | ||||||||
} | ||||||||
|
||||||||
// Add for fixed notification | ||||||||
if (!buildData.settings.slack.statuses.includes('SUCCESS') && buildData.isFixed) { | ||||||||
buildData.settings.slack.statuses.push('SUCCESS'); | ||||||||
} | ||||||||
|
||||||||
if (!buildData.settings.slack.statuses.includes(buildData.status)) { | ||||||||
return; | ||||||||
} | ||||||||
|
@@ -147,11 +155,20 @@ class SlackNotifier extends NotificationBase { | |||||||
buildData.event.commit.message; | ||||||||
const isMinimized = buildData.settings.slack.minimized; | ||||||||
|
||||||||
// When using multiple notification plugins,Do not change the `buildData.status` directly | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me suggest.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. |
||||||||
let notificationStatus = buildData.status; | ||||||||
|
||||||||
if (buildData.settings.slack.statuses.includes('FAILURE')) { | ||||||||
if (buildData.status === 'SUCCESS' && buildData.isFixed) { | ||||||||
notificationStatus = 'FIXED'; | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
let message = isMinimized ? | ||||||||
// eslint-disable-next-line max-len | ||||||||
`<${pipelineLink}|${buildData.pipeline.scmRepo.name}#${buildData.jobName}> *${buildData.status}*` : | ||||||||
`<${pipelineLink}|${buildData.pipeline.scmRepo.name}#${buildData.jobName}> *${notificationStatus}*` : | ||||||||
// eslint-disable-next-line max-len | ||||||||
`*${buildData.status}* ${STATUSES_MAP[buildData.status]} <${pipelineLink}|${buildData.pipeline.scmRepo.name} ${buildData.jobName}>`; | ||||||||
`*${notificationStatus}* ${STATUSES_MAP[notificationStatus]} <${pipelineLink}|${buildData.pipeline.scmRepo.name} ${buildData.jobName}>`; | ||||||||
|
||||||||
const metaMessage = hoek.reach(buildData, | ||||||||
'build.meta.notification.slack.message', { default: false }); | ||||||||
|
@@ -170,7 +187,7 @@ class SlackNotifier extends NotificationBase { | |||||||
[ | ||||||||
{ | ||||||||
fallback: '', | ||||||||
color: COLOR_MAP[buildData.status], | ||||||||
color: COLOR_MAP[notificationStatus], | ||||||||
fields: [ | ||||||||
{ | ||||||||
title: 'Build', | ||||||||
|
@@ -183,7 +200,7 @@ class SlackNotifier extends NotificationBase { | |||||||
[ | ||||||||
{ | ||||||||
fallback: '', | ||||||||
color: COLOR_MAP[buildData.status], | ||||||||
color: COLOR_MAP[notificationStatus], | ||||||||
title: `#${buildData.build.id}`, | ||||||||
title_link: `${buildData.buildLink}`, | ||||||||
// eslint-disable-next-line max-len | ||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it nicer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good!
We'll modify it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing. Is there any problem on updating with
buildData.settings.slack.statuses.push('FIXED');
for multiple plugins? I think it is OK if it does not update DB.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay because it's only slack that's set up.
buildData.settings.[slack].statuses
For example, for the email plugin, this is set as follows
buildData.settings.[email].statuses
There is no process to update the DB in each notification plugin, so I think okay.