mattermost_notifier.rb 839 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. require "../support/requester"
  2. require "time"
  3. class MattermostNotifier
  4. class << self
  5. def review_message(results)
  6. color_map = {
  7. 1 => 'danger',
  8. 2 => '#ff4500',
  9. 3 => 'warning',
  10. 4 => '#9acd32',
  11. 5 => 'good',
  12. }
  13. text = "|QA_Test|Status: Mac Web, #{Time.now.strftime('%Y-%m-%d_%H.%M.%S')}|Link|\n"
  14. text+= "|:---|:---|:---|\n"
  15. text+= results
  16. content = {
  17. attachments: [
  18. {
  19. color: color_map[5],
  20. text: text
  21. }
  22. ]
  23. }
  24. #find which channel should go
  25. publish(content, "/hooks/d8i7w5sktfr5i864bcqsc8ieto")
  26. end
  27. private
  28. def publish(message_content, path)
  29. host = Requester.new('http://chat.kdanmobile.com')
  30. host.json_send(:post, path, message_content)
  31. end
  32. end
  33. end