diff --git a/lib/pact_broker/locale/en.yml b/lib/pact_broker/locale/en.yml index 6d5417f93..6d37fd1f5 100644 --- a/lib/pact_broker/locale/en.yml +++ b/lib/pact_broker/locale/en.yml @@ -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 diff --git a/lib/pact_broker/webhooks/pact_and_verification_parameters.rb b/lib/pact_broker/webhooks/pact_and_verification_parameters.rb index 53bbea394..356369f2a 100644 --- a/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +++ b/lib/pact_broker/webhooks/pact_and_verification_parameters.rb @@ -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" @@ -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, @@ -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, @@ -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) diff --git a/spec/lib/pact_broker/webhooks/render_spec.rb b/spec/lib/pact_broker/webhooks/render_spec.rb index e7ada1cbc..d8b9c98bd 100644 --- a/spec/lib/pact_broker/webhooks/render_spec.rb +++ b/spec/lib/pact_broker/webhooks/render_spec.rb @@ -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],