Hello! I am trying to understand how the environme...
# pact-broker
b
Hello! I am trying to understand how the environment is set for the pacts published in the broker (I'm using pactflow). Is it through
record-deployment
?
y
hey, via recording releases or deployments, environments can be created beforehand. By default prod and test exist (at least in PactFlow) https://docs.pact.io/pact_broker/recording_deployments_and_releases#environments
b
I see, so when I publish a contract, the environment is not set yet... like this:
then if I record deployment/release, the environment will be set... alright.
y
correct, you publish with a version, and optionally branch or tag. you record a release/deployment as an additional step (after having verified contracts, and having called can-i-deploy for the version to that environment, which returns a success )
b
@Yousaf Nabi (pactflow.io) thanks... I think I got it now, the correct order of the processes were not clear to me. In my mind, please let me know if I am completely wrong... 1. Consumer publishers a contract (no env) 2. Provider make some changes and verify the contract (no env) a. Here, both can-i-deploy (no env) are valid. b. For the ProviderProducer, can-i-deploy for env
test
and
production
are OK. c. For the Consumer, can-i-deploy for env
test
and
production
are NOT OK. 3. Then the Provider deploys to
test
and after the completed deployment, a
record-deployment
is sent to the broker with
--environment test
. The pact now has the Environment
Test
marked on it (provider side). 4. Now, for the Consumer, can-i-deploy for env
test
is OK. 5. Consumer can deploy, and send a
record-deployment
too, it marks the Environment
Test
on the pact (consumer side) Same stuff for Prod... After deploying in Prod, will it mark
Test
and
Prod
? Or will just be replaced with
Prod
? Thanks.
y
1. Consumer publishers a contract (no env) ✅ (Ideally with a branch and always an application version, ideally git sha) 2. Provider make some changes and verify the contract (no env) a. Here, both can-i-deploy (no env) are valid. ⚠️ - I wouldn’t do can-i-deploy with no environment, you could use can-i-merge (to main line) - if you don’t have envs setup yet. b. For the ProviderProducer, can-i-deploy for env
test
and
production
are OK. ✅ - provider can deploy to any env if they aren’t reliant on any consumers. no consumers currently in test or prod, so its ok. c. For the Consumer, can-i-deploy for env
test
and
production
are NOT OK. ✅ - correct, the provider is not deployed to production, so even if the contract is valid with the providers main branch, its not got any deployed versions 3. Then the Provider deploys to
test
and after the completed deployment, a
record-deployment
is sent to the broker with
--environment test
. The pact now has the Environment
Test
marked on it (provider side). ✅ 4. Now, for the Consumer, can-i-deploy for env
test
is OK. ✅ 5. Consumer can deploy, and send a
record-deployment
too, it marks the Environment
Test
on the pact (consumer side) ✅ Same stuff for Prod... After deploying in Prod, will it mark
Test
and
Prod
? Or will just be replaced with
Prod
? ❓ - A provider may not mirror the same environments as the consumer. This is OK, Pact Broker will keep track of the environments associated consumers and providers exist in. msn lightbulb In your scenario, in step 3, the provider version is already marked as deployed into
Test
and therefore if you are just deployed to prod, you would
record-deployment
is sent to the broker with
--environment prod
There would be no harm in re-recording the same version into test
Sounds like you’ve got it 🙂
🎉 1