Skip to content

Commit cdcc85d

Browse files
committed
Add support to publish verification result to pact broker
1 parent c1a5402 commit cdcc85d

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

pact/verify.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@
5151
help='The duration in seconds we should wait to confirm verification'
5252
' process was successful. Defaults to 30.',
5353
type=int)
54+
@click.option(
55+
'provider_app_version', '-a', '--provider-app-version',
56+
help='The provider application version, required for publishing verification results'
57+
)
58+
@click.option(
59+
'publish_verification_results', '-r', '--publish-verification-results',
60+
default=False,
61+
help='Publish verification results to the broker',
62+
is_flag=True,)
63+
5464
def main(base_url, pact_url, pact_urls, states_url, states_setup_url, username,
55-
password, timeout):
65+
password, timeout, provider_app_version, publish_verification_results):
5666
"""
5767
Verify one or more contracts against a provider service.
5868
@@ -94,10 +104,19 @@ def main(base_url, pact_url, pact_urls, states_url, states_setup_url, username,
94104
'--broker-username': username,
95105
'--broker-password': password
96106
}
97-
107+
98108
command = [VERIFIER_PATH] + [
99109
'{}={}'.format(k, v) for k, v in options.items() if v]
100-
110+
111+
if publish_verification_results:
112+
if not provider_app_version:
113+
click.echo(
114+
error
115+
+ 'Provider application version is required '
116+
+ 'to publish verification results to broker'
117+
)
118+
raise click.Abort()
119+
command.extend(["--provider-app-version", provider_app_version, "--publish-verification-results"])
101120
p = subprocess.Popen(command)
102121
p.communicate(timeout=timeout)
103122
sys.exit(p.returncode)

0 commit comments

Comments
 (0)