Sha256: 13c41c81624bc7effd8f93790707084c12af2329233696dc737e209e6ae40a66
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require 'faraday' module Travis module Notifications class Webhook autoload :Payload, 'travis/notifications/webhook/payload' EVENTS = 'build:finished' class << self def payload_for(build) Payload.new(build).to_hash end end cattr_accessor :http_client self.http_client = Faraday.new do |f| f.request :url_encoded f.adapter :net_http end def notify(event, build, *args) send_webhook_notifications(build.webhooks, build) if build.send_webhook_notifications? end protected def send_webhook_notifications(targets, build) targets.each do |webhook| self.class.http_client.post(webhook) do |req| req.body = { :payload => self.class.payload_for(build).to_json } req.headers['Authorization'] = authorization(build) end end end def authorization(build) Digest::SHA2.hexdigest(build.repository.slug + build.request.token) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
travis-core-0.0.1 | lib/travis/notifications/webhook.rb |