Skip to content

Commit 7bdf0c4

Browse files
richard-reecebethesque
authored andcommitted
feat(webhooks): provide mapping to bitbucket build status names (pact-foundation#277)
1 parent 9439cc8 commit 7bdf0c4

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lib/pact_broker/doc/views/webhooks.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ The following variables may be used in the request path, parameters or body, and
9595
* `${pactbroker.consumerLabels}`: the list of labels for the consumer associated with the pact content, separated by ", ".
9696
* `${pactbroker.providerLabels}`: the list of labels for the provider associated with the pact content, separated by ", ".
9797
* `${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).
98+
* `${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/).
9899
* `${pactbroker.pactUrl}`: the "permalink" URL to the newly published pact (the URL specifying the consumer version URL, rather than the "/latest" format.)
99100
* `${pactbroker.verificationResultUrl}`: the URL to the relevant verification result.
100101

lib/pact_broker/webhooks/pact_and_verification_parameters.rb

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def to_hash
2020
'${pactbroker.consumerName}' => pact ? pact.consumer_name : "",
2121
'${pactbroker.providerName}' => pact ? pact.provider_name : "",
2222
'${pactbroker.githubVerificationStatus}' => github_verification_status,
23+
'${pactbroker.bitbucketVerificationStatus}' => bitbucket_verification_status,
2324
'${pactbroker.consumerLabels}' => pacticipant_labels(pact && pact.consumer),
2425
'${pactbroker.providerLabels}' => pacticipant_labels(pact && pact.provider)
2526
}
@@ -29,6 +30,13 @@ def to_hash
2930

3031
attr_reader :pact, :verification, :webhook_context, :base_url
3132

33+
def bitbucket_verification_status
34+
if verification
35+
verification.success ? "SUCCESSFUL" : "FAILED"
36+
else
37+
"INPROGRESS"
38+
end
39+
end
3240

3341
def github_verification_status
3442
if verification

spec/lib/pact_broker/webhooks/render_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ module Webhooks
112112
["${pactbroker.githubVerificationStatus}", "pending", :pact_with_no_verification, :nil_verification],
113113
["${pactbroker.githubVerificationStatus}", "success", :pact_with_successful_verification, :nil_verification],
114114
["${pactbroker.githubVerificationStatus}", "failure", :pact_with_failed_verification, :nil_verification],
115+
["${pactbroker.bitbucketVerificationStatus}", "SUCCESSFUL", :pact, :verification],
116+
["${pactbroker.bitbucketVerificationStatus}", "FAILED", :pact, :failed_verification],
117+
["${pactbroker.bitbucketVerificationStatus}", "INPROGRESS", :nil_pact, :nil_verification],
118+
["${pactbroker.bitbucketVerificationStatus}", "INPROGRESS", :pact_with_no_verification, :nil_verification],
119+
["${pactbroker.bitbucketVerificationStatus}", "SUCCESSFUL", :pact_with_successful_verification, :nil_verification],
120+
["${pactbroker.bitbucketVerificationStatus}", "FAILED", :pact_with_failed_verification, :nil_verification],
115121
["${pactbroker.verificationResultUrl}", "", :pact_with_no_verification, :nil_verification],
116122
["${pactbroker.verificationResultUrl}", "http://verification", :pact_with_successful_verification, :nil_verification],
117123
["${pactbroker.verificationResultUrl}", "http://verification", :pact_with_successful_verification, :verification],

0 commit comments

Comments
 (0)