Sha256: 317fcd7ce2e1efae52c3ad6c6fa372b8912e1bd5cce452a77ca6873f500ca02b
Contents?: true
Size: 1.09 KB
Versions: 47
Compression:
Stored size: 1.09 KB
Contents
require 'sucker_punch' require 'faraday' require 'pact_broker/logging' # Publishes verification results, as if they were triggered by a CI job module PactBroker class VerificationJob include SuckerPunch::Job include PactBroker::Logging def perform data pact_url = data.fetch(:pactUrl) pact = Faraday.get(pact_url, nil, { 'Accept' => 'application/hal+json'}).body pact_hash = JSON.parse(pact) headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json' } provider_version = "1.2.#{(rand * 1000).to_i}" provider_url = pact_hash['_links']['pb:provider']['href'] Faraday.put("#{provider_url}/versions/#{provider_version}/tags/dev", nil, headers) verification_url = pact_hash['_links']['pb:publish-verification-results']['href'] body = { success: true, providerApplicationVersion: provider_version } Faraday.post(verification_url, body.to_json, headers) sleep 3 Faraday.put("#{provider_url}/versions/#{provider_version}/tags/prod", nil, headers) end end end
Version data entries
47 entries across 47 versions & 1 rubygems