Skip to content

Commit

Permalink
feat: add pactbroker.azureDevOpsVerificationStatus webhook parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 9, 2021
1 parent c333e32 commit 8804a90
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/pact_broker/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ en:
providerLabels: The list of labels for the provider associated with the pact content, separated by ", ".
pactUrl: The "permalink" URL to the newly published pact (the URL specifying the consumer version URL, rather than the "/latest" format.
verificationResultUrl: The URL to the relevant verification result.
githubVerificationStatus: The verification status using the correct keywords for posting to the Github commit status API. See https://developer.github.com/v3/repos/statuses.
bitbucketVerificationStatus: The verification status using the correct keywords for posting to the Bitbucket commit status API. See https://developer.atlassian.com/server/bitbucket/how-tos/updating-build-status-for-commits/.
githubVerificationStatus: The verification status using the correct keywords for posting to the Github commit status API. See https://developer.github.com/v3/repos/statuses
bitbucketVerificationStatus: The verification status using the correct keywords for posting to the Bitbucket commit status API. See https://developer.atlassian.com/server/bitbucket/how-tos/updating-build-status-for-commits/
azureDevOpsVerificationStatus: The verification status using the correct keywords for posting to the Azure DevOps GitStatusState API. See https://docs.microsoft.com/en-us/rest/api/azure/devops/git/statuses/create?view=azure-devops-rest-6.0
eventName: The name of the event that triggered the webhook
currentlyDeployedProviderVersionNumber: The version number of the currently deployed provider version (when used in a template, the webhook will be triggered once for each currently deployed provider version)
no_webhooks_enabled_for_event: No enabled webhooks found for the detected events
Expand Down
11 changes: 11 additions & 0 deletions lib/pact_broker/webhooks/pact_and_verification_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PactAndVerificationParameters
PROVIDER_NAME = "pactbroker.providerName"
GITHUB_VERIFICATION_STATUS = "pactbroker.githubVerificationStatus"
BITBUCKET_VERIFICATION_STATUS = "pactbroker.bitbucketVerificationStatus"
AZURE_DEV_OPS_VERIFICATION_STATUS = "pactbroker.azureDevOpsVerificationStatus"
CONSUMER_LABELS = "pactbroker.consumerLabels"
PROVIDER_LABELS = "pactbroker.providerLabels"
EVENT_NAME = "pactbroker.eventName"
Expand All @@ -31,6 +32,7 @@ class PactAndVerificationParameters
VERIFICATION_RESULT_URL,
GITHUB_VERIFICATION_STATUS,
BITBUCKET_VERIFICATION_STATUS,
AZURE_DEV_OPS_VERIFICATION_STATUS,
CONSUMER_LABELS,
PROVIDER_LABELS,
EVENT_NAME,
Expand Down Expand Up @@ -59,6 +61,7 @@ def to_hash
PROVIDER_NAME => pact ? pact.provider_name : "",
GITHUB_VERIFICATION_STATUS => github_verification_status,
BITBUCKET_VERIFICATION_STATUS => bitbucket_verification_status,
AZURE_DEV_OPS_VERIFICATION_STATUS => azure_dev_ops_verification_status,
CONSUMER_LABELS => pacticipant_labels(pact && pact.consumer),
PROVIDER_LABELS => pacticipant_labels(pact && pact.provider),
EVENT_NAME => event_name,
Expand Down Expand Up @@ -87,6 +90,14 @@ def github_verification_status
end
end

def azure_dev_ops_verification_status
if verification
verification.success ? "succeeded" : "failed"
else
"notSet"
end
end

def verification_url
if verification
PactBroker::Api::PactBrokerUrls.verification_url(verification, base_url)
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/pact_broker/webhooks/render_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ module Webhooks
["${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.azureDevOpsVerificationStatus}", "succeeded", :pact, :verification],
["${pactbroker.azureDevOpsVerificationStatus}", "failed", :pact, :failed_verification],
["${pactbroker.azureDevOpsVerificationStatus}", "notSet", :nil_pact, :nil_verification],
["${pactbroker.azureDevOpsVerificationStatus}", "notSet", :pact_with_no_verification, :nil_verification],
["${pactbroker.azureDevOpsVerificationStatus}", "succeeded", :pact_with_successful_verification, :nil_verification],
["${pactbroker.azureDevOpsVerificationStatus}", "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],
Expand Down

0 comments on commit 8804a90

Please sign in to comment.