Add a link to Slack notification for silenced RuboCop offenses
What does this MR do and why?
This MR documents how to fix Slack notification message related to silenced RuboCop offenses.
It also refines the notification message to show the documentation link as a breadcrumb.
Screenshots or screen recordings
Slack notification |
---|
How to set up and validate locally
rspec spec/rubocop/check_graceful_task_spec.rb`
Notification testing
- Export needed envvars:
export CI_JOB_NAME="update-static-analysis-cache"
export CI_JOB_URL=https://gitlab.com/gitlab-org/gitlab/-/jobs/3094949954
# See Settings > CI/CD > Variables
export CI_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXX/YYY/ZZZ
- Change Slack channel to avoid spam:
diff --git a/rubocop/check_graceful_task.rb b/rubocop/check_graceful_task.rb
index 724f7fa6963..88b9b12ce7d 100644
--- a/rubocop/check_graceful_task.rb
+++ b/rubocop/check_graceful_task.rb
@@ -65,7 +65,7 @@ def notify_slack
return
end
- channel = 'f_rubocop'
+ channel = 'chat-ops-test'
message = format(
':warning: `%{job_name}` passed :green: but contained <%{job_url}|silenced offenses>. ' \
'See <%{docs_link}|docs>.',
- Trigger notification
ruby -r./rubocop/check_graceful_task -e 'RuboCop::CheckGracefulTask.new($stdout).send(:notify_slack)'
Notifying Slack #chat-ops-test.
- Verify the notification in
#chat-opt-test
(internal) (or see screenshot above) - Cleanup
unset CI_JOB_NAME
unset CI_JOB_URL
unset CI_SLACK_WEBHOOK_URL
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen