Class: Rodbot::Plugins::GitlabWebhook::App::Routes

Inherits:
App
  • Object
show all
Defined in:
lib/rodbot/plugins/gitlab_webhook/app.rb

Constant Summary collapse

DEFAULT_HANDLER =
->(request) do
  json = JSON.parse(request.body.read)
  if json['object_kind'] == 'pipeline'
    project = json.dig('project', 'path_with_namespace')
    status = json.dig('object_attributes', 'detailed_status')
    emoji = case status
      when 'running' then '🟡'
      when 'passed' then '🟢'
      when 'failed' then '🔴'
      else '⚪️'
    end
    [emoji, project, status.gsub('_', ' ')].join(' ')
  end
end