Hi All, I am trying to build the provider pipeline...
# pact-broker
g
Hi All, I am trying to build the provider pipeline in bamboo cicd. As part of CI the pact broker can-i-deploy cli command for the to-environment with "Staging" (which is not available in respected consumer), is returning "yes" (Attached screenshot), but ideally it should give "no" right? Please confirm if it's expected behaviour. The same way I have tried from consumer end, it's giving me "no" (attached screenshot). Kindly help me if anything I have missed to check here. #C9VPNUJR2
👋 1
👍 2
m
if the consumer hasn’t been deployed to staging, then it is perfectly safe for the provider to do so - it won’t break any dependencies in that environment
It’s not safe the other way around, for the same reason but in reverse. If the consumer were to deploy, there is no provider there (if there is no recorded deployment for it) or the provider may or may not be compatible with the consumer. Either way, we are not confident it’s safe to deploy
g
Thanks for your reply @Matt (pactflow.io / pact-js / pact-go) There was some miscommunication in the previous question. Reframing the question here Scenario1: When two consumers(different environments) with one provider as shown below, then how can we pass the to-environment in provider's pipeline can-i-deploy?
Copy code
Consumer 1		    Provider 1
1.1(Preprod)		1.2(Staging)
		
Consumer 2		    Provider 1
2.1(Staging)		1.2(Staging)
Scenario2: When two providers(different environments) with one consumer as shown below, then how can we pass the to-environment in consumer pipeline can-i-deploy?
Copy code
Consumer 3		    Provider 2
3.1 (Preprod)		2.1(Staging)
		
Consumer 3		    Provider 3
3.1 (Preprod)		2.1(SIT)
#C9VPNUJR2
m
The answer is always the same. You're asking the question "is it safe to deploy some application to some environment" Replace application and environment with what you wish to deploy and where to deploy it
The Pact Broker works out the dependencies and checks if they'll be satisfied or you were to deploy or not, and tell you why if not
g
So you are suggesting, in this case do I need to do multiple can-i-deploy calls for each environment before deployment as below? Scenario1 - Provider can-i-deploy pact-broker can-i-deploy --pacticipant Provider1 --version 1.2 --to-environment Preprod pact-broker can-i-deploy --pacticipant Provider2 --version 1.2 --to-environment Staging Scenario2 - Consumer can-i-deploy pact-broker can-i-deploy --pacticipant Consumer3 --version 3.1 --to-environment Staging pact-broker can-i-deploy --pacticipant Consumer3 --version 3.1 --to-environment SIT #C9VPNUJR2
m
well, I don’t know what you need to check if it’s safe to deploy to
SIT
if you plan on deploying to
Preprod
for example (and vice versa)
Unless you always deploy to both at the same time, in which case, yes yo uwould
g
Hi, Example scenario on the similar notes, Scenario: Consumer Foo with two providers Bar and Baz. Consumer(Foo) environments mapped with Provider environment as follows, • Foo - prod is pointed to Bar(production) and Baz(prod) environments • Foo - stag is pointed to Bar(staging) and Baz(preprod) environments • Foo - sit is pointed to Bar(sit) and Baz(dev) environments • Bar and Baz deployed their code in all the environments for Foo version 22, pact-broker matrix as below Foo version(consumer) Bar version(provider1) Verification success? 22(prod, stag, sit) 56(production, staging, sit) True Foo version(consumer) Baz version(provider2) Verification success? 22(prod, stag, sit) 66(prod, preprod, dev) True • Foo did some change in contract and publish the new contract (23), now pact broker matrix as below Foo version(consumer) Bar version(provider1) Verification success? 22(prod, stag, sit) 56(production, staging, sit) True 23(main) 56(production, staging, sit) True Foo version(consumer) Baz version(provider2) Verification success? 22(prod, stag, sit) 66(prod, preprod, dev) True 23(main) 66(prod, preprod, dev) False Foo pipeline configured for can-i-deploy for each environment as below order • Build and Publish contract • Can-I-deploy sit ( it will fail for first time and will resuming the pipeline once provider verification done successfully, in this case Bar will resume) • Deploy in SIT • Can-I-deploy stag • Deploy in Staging • Can-I-Deploy prod • Deploy in PROD As per the document, can-i-deploy checks only one *--to-environment (provider env)* at a time, so in this case since Foo having two providers (Bar and Baz), Can-I-deploy SIT pipeline task should check for both providers as below ? pact-broker can-i-deploy --pacticipant Foo --version 23 --to-environment sit (Bar environment) pact-broker can-i-deploy --pacticipant Foo --version 23 --to-environment dev (Baz environment)
Hi Team, Did you get a chance to check this ? Thanks!
m
Why are apps in one environment pointing to apps across others? In any case, yes you would need to call it for each environment you want to check. You would also need to deploy it to the target environments otherwise the reciprocal check won't be valid (i.e. the provider might think it's safe to deploy because the consumer is in SIT no pre prod)
g
It could be possible where consumer is with one team where they are using their own deployment strategies similarly for provider too. BTW thanks for your reply!
m
no worries!
Mind elaborating a bit more on the reason for applications crossing environment boundaries?
g
To give more information, we are trying adopt the contract testing with some of the legacy teams where they are still using the legacy deployment approach, like master branch, DEV, SIT and Prod environments. And this team would be a provider service for some other consumer teams. So we are seeing the environments/branches are completely different between provider and consumer's end. #C9VPNUJR2
m
The branches lining up is an independent problem to deployments. What you care about, is ensuring application A is compatible with application B in the environments they need to work in.
can-i-deploy
gives you the ability to do that, you just have to do it in multiple calls
g
Thanks for your reply. Is it feasible to check with one
can-i-deploy
command to verifiy more than one environment at a time? I had a look into the
can-i-deploy
command, it's allowing only one with
--to-environment
. Appreciate if you could respond. Thank you!
m
no, not at the moment. You can just call the CLI twice for that
👍 1