summaryrefslogtreecommitdiff
path: root/app/models/project_services/hipchat_service.rb
diff options
context:
space:
mode:
authorDavid Eisner <david.eisner@oriel.oxon.org>2016-01-06 16:01:48 +0000
committerRémy Coutable <remy@rymai.me>2016-07-26 11:56:56 +0200
commit189e3b575a739c65665af172d607eded967d348f (patch)
tree0a5bb447cde97f0a51de1b596bfd93fd1afaf804 /app/models/project_services/hipchat_service.rb
parente9946f19a5af84b13fc8f21bdffa0689fd93f6c3 (diff)
downloadgitlab-ce-189e3b575a739c65665af172d607eded967d348f.tar.gz
HipChat notification color overridden by build status
Diffstat (limited to 'app/models/project_services/hipchat_service.rb')
-rw-r--r--app/models/project_services/hipchat_service.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index 23e5b16221b..413200199b4 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -46,7 +46,7 @@ class HipchatService < Service
return unless supported_events.include?(data[:object_kind])
message = create_message(data)
return unless message.present?
- gate[room].send('GitLab', message, message_options)
+ gate[room].send('GitLab', message, message_options(data))
end
def test(data)
@@ -67,8 +67,8 @@ class HipchatService < Service
@gate ||= HipChat::Client.new(token, options)
end
- def message_options
- { notify: notify.present? && notify == '1', color: color || 'yellow' }
+ def message_options(data)
+ { notify: notify.present? && notify == '1', color: build_status_color(data) || color || 'yellow' }
end
def create_message(data)
@@ -240,6 +240,14 @@ class HipchatService < Service
"#{project_link}: Commit #{commit_link} of #{branch_link} #{ref_type} by #{user_name} #{humanized_status(status)} in #{duration} second(s)"
end
+ def build_status_color(data)
+ if data[:commit][:status] == 'success'
+ 'green'
+ else
+ 'red'
+ end if data[:object_kind] == 'build'
+ end
+
def project_name
project.name_with_namespace.gsub(/\s/, '')
end