Pact-jvm: Publish verification results with a version tag in pact-jvm-provider-spring_2.12

Created on 3 Dec 2018  路  15Comments  路  Source: pact-foundation/pact-jvm

Hi,
When I want to publish verification results to my pact broker I have to add:

pact.verifier.publishResults=true

alongside with the provider version:

pact.provider.version=0.0.1

My question is: How do I specify the provider tag?
I haven't seen an option to do that in pact-jvm-provider-spring or in pact-jvm-provider-junit..

enhancement

Most helpful comment

I need to add this to the ruby impl too, if I haven't already. While you're waiting for this feature, you can either do a curl to PUT the tag in the right place via the API, or use the pact broker client.

All 15 comments

That is a good question. The way the verifications work is they publish the results back based on the pact URL that was fetched for the test. So when you specify the tag in the test, this will point to a version of the pact file (tags are just labels to a pact file version), and the verification will be posted back against that version.

That is my understanding, but @bethesque is probably the only person who really understands this stuff.

That is a good question. The way the verifications work is they publish the results back based on the pact URL that was fetched for the test. So when you specify the tag in the test, this will point to a version of the pact file (tags are just labels to a pact file version), and the verification will be posted back against that version.

That is my understanding, but @bethesque is probably the only person who really understands this stuff.

Thanks for the quick answer.
Actually, I am talking about the version/tag of the provider rather than the version/tag of the pact file..
with pact.provider.version I can specify the provider version.
It would make sense if I had an option to use something like pact.provider.tag... That's what I am looking for.

I need to add this to the ruby impl too, if I haven't already. While you're waiting for this feature, you can either do a curl to PUT the tag in the right place via the API, or use the pact broker client.

+1. I really could use the above feature, in the gradle plugin implementation.

I need to add this to the ruby impl too, if I haven't already. While you're waiting for this feature, you can either do a curl to PUT the tag in the right place via the API, or use the pact broker client.

Is there a link to the specific req in the API docs to version the provider? Don't want to tag the file just the provider version. Thanks!

I need to add this to the ruby impl too, if I haven't already. While you're waiting for this feature, you can either do a curl to PUT the tag in the right place via the API, or use the pact broker client.

@bethesque as discussed on slack, this would help tag the provider later, but the tags info won't be part of the _provider_verification_published_ webhook, which is I guess required if you have to retrigger _can-i-deploy_ on consumer side.

The only workaround I see at the moment is to configure a retry in _can-i-deploy_.
@bethesque correct me if I am wrong.

You can always run the tagging code before you execute the pact tests. It's designed so that you tag first.

@bethesque Do I post/put the tag to the provider to pb:pacticipant-version-tag?

Hm, no unfortunately, that will tag the consumer. In the Ruby code, I've fetched the pb:provider and then used the pb:version-tag relation. I've got code in there that falls back to a hardcoded URL if those relations can't be found though.

4.0.1 has been released

In provider side, even if specify in JVM system properties System.setProperty("pact.provider.tag", "dev") ,the tag is not included in broker

I think the provider tag parameter is missing in the verificationReporter.reportResults function:

https://github.com/DiUS/pact-jvm/blob/4_0_1/provider/pact-jvm-provider/src/main/kotlin/au/com/dius/pact/provider/TestResultAccumulator.kt#L55-L57

Below is my code, I can publish provider version,but the tag name is not publishing to pact broker

@MockBean
private Service service;

@BeforeEach
public void setupTestTarget(PactVerificationContext context) {
context.setTarget(new HttpTestTarget("localhost", 3412, "/adapter-litka"));

System.setProperty("pact.provider.tag", "dev");
System.setProperty("pact.provider.version", "version1");
System.setProperty("pact.verifier.publishResults", "true");

System.out.println(System.getProperties());

}

@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
public void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}

@State("status endpoint is up")
public void toGetState() {
String customerId = "00086330";
Dto dto = new Dto();
dto.setCustomerId("xxxxx"); when(service.getDtos(eq(customerId))).thenReturn(Collections.singletonList(dto));
}

4.0.1 has been released

In this version provider can't send tag name to Pact broker.As you see my from code, I'am setting pact.provider.tag but this code is not working.Provider version is publishing to Pact Broker, but tag name not

Good catch @l-lin! This should be fixed now for JUnit based tests

Was this page helpful?
0 / 5 - 0 ratings