Sha256: 28e50467f898460d7ca050facbe7a71eb84b436a4f62bf0181e62100e84ea6a6

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

namespace :cogy do
  desc "Invoke the Cog Trigger that will install the Cogy-generated bundle"
  task :notify_cog do
    require "net/http"
    require "timeout"
    require "json"

    trigger_url = fetch(:cogy_release_trigger_url)
    cogy_endpoint = Cogy.cogy_endpoint

    begin
      raise ":cogy_release_trigger_url must be set" if trigger_url.nil?
      raise "Cogy.cogy_endpoint must be set" if cogy_endpoint.nil?

      Timeout.timeout(fetch(:cogy_trigger_timeout) || 7) do
        url = URI(trigger_url)
        res = Net::HTTP.post_form(url, url: cogy_endpoint)

        if !res.is_a?(Net::HTTPSuccess)
          error = JSON.parse(res.body)["errors"]["error_message"]
          if error !~ /version has already been taken/
            puts "Error response (#{res.code}) from Cog trigger: #{error}"
          end
        end
      end
    rescue => e
      puts "Error invoking Cog trigger: #{e.class} #{e.message}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cogy-0.5.0 lib/cogy/capistrano/cogy.rake