diff --git a/lib/pact_broker/doc/views/webhooks.markdown b/lib/pact_broker/doc/views/webhooks.markdown index f6d856233..7a991d313 100644 --- a/lib/pact_broker/doc/views/webhooks.markdown +++ b/lib/pact_broker/doc/views/webhooks.markdown @@ -95,6 +95,7 @@ The following variables may be used in the request path, parameters or body, and * `${pactbroker.consumerLabels}`: the list of labels for the consumer associated with the pact content, separated by ", ". * `${pactbroker.providerLabels}`: the list of labels for the provider associated with the pact content, separated by ", ". * `${pactbroker.githubVerificationStatus}`: the verification status using the correct keywords for posting to the the [Github commit status API](https://developer.github.com/v3/repos/statuses). +* `${pactbroker.bitbucketVerificationStatus}`: the verification status using the correct keywords for posting to the the [Bitbucket commit status API](https://developer.atlassian.com/server/bitbucket/how-tos/updating-build-status-for-commits/). * `${pactbroker.pactUrl}`: the "permalink" URL to the newly published pact (the URL specifying the consumer version URL, rather than the "/latest" format.) * `${pactbroker.verificationResultUrl}`: the URL to the relevant verification result. diff --git a/lib/pact_broker/webhooks/pact_and_verification_parameters.rb b/lib/pact_broker/webhooks/pact_and_verification_parameters.rb index 526c93a87..cd2e2ae4a 100644 --- a/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +++ b/lib/pact_broker/webhooks/pact_and_verification_parameters.rb @@ -20,6 +20,7 @@ def to_hash '${pactbroker.consumerName}' => pact ? pact.consumer_name : "", '${pactbroker.providerName}' => pact ? pact.provider_name : "", '${pactbroker.githubVerificationStatus}' => github_verification_status, + '${pactbroker.bitbucketVerificationStatus}' => bitbucket_verification_status, '${pactbroker.consumerLabels}' => pacticipant_labels(pact && pact.consumer), '${pactbroker.providerLabels}' => pacticipant_labels(pact && pact.provider) } @@ -29,6 +30,13 @@ def to_hash attr_reader :pact, :verification, :webhook_context, :base_url + def bitbucket_verification_status + if verification + verification.success ? "SUCCESSFUL" : "FAILED" + else + "INPROGRESS" + end + end def github_verification_status if verification diff --git a/spec/lib/pact_broker/webhooks/render_spec.rb b/spec/lib/pact_broker/webhooks/render_spec.rb index 70da99593..eef5ff266 100644 --- a/spec/lib/pact_broker/webhooks/render_spec.rb +++ b/spec/lib/pact_broker/webhooks/render_spec.rb @@ -112,6 +112,12 @@ module Webhooks ["${pactbroker.githubVerificationStatus}", "pending", :pact_with_no_verification, :nil_verification], ["${pactbroker.githubVerificationStatus}", "success", :pact_with_successful_verification, :nil_verification], ["${pactbroker.githubVerificationStatus}", "failure", :pact_with_failed_verification, :nil_verification], + ["${pactbroker.bitbucketVerificationStatus}", "SUCCESSFUL", :pact, :verification], + ["${pactbroker.bitbucketVerificationStatus}", "FAILED", :pact, :failed_verification], + ["${pactbroker.bitbucketVerificationStatus}", "INPROGRESS", :nil_pact, :nil_verification], + ["${pactbroker.bitbucketVerificationStatus}", "INPROGRESS", :pact_with_no_verification, :nil_verification], + ["${pactbroker.bitbucketVerificationStatus}", "SUCCESSFUL", :pact_with_successful_verification, :nil_verification], + ["${pactbroker.bitbucketVerificationStatus}", "FAILED", :pact_with_failed_verification, :nil_verification], ["${pactbroker.verificationResultUrl}", "", :pact_with_no_verification, :nil_verification], ["${pactbroker.verificationResultUrl}", "http://verification", :pact_with_successful_verification, :nil_verification], ["${pactbroker.verificationResultUrl}", "http://verification", :pact_with_successful_verification, :verification],