0.0.4 • Published 4 years ago
@rplan/pact-broker-helper v0.0.4
Pact Broker
How to access the pact broker ui
The UI is protected by basic auth, you can get the credentials using the command bellow:
vault read secret/rplanx/gke-dev/pact-broker
How to setup a pact communication (Consumer -> Provider)
Consumer
- (1) Install pact-broker-cli as dev dependency
- (2) First thing you have to do is defining what you need from the provider (pact definition) Example
- (3) Run your api tests against the pact definition (it will generate a pact file) Example
- (4) Publish your pact file to the pact broker Example
- (5) Create a webhook between consumer -> provider Example
Provider
- (5) Add verify pacts test file Example
- (6) Configure pact variables Example
- (7) Add "Verify Pacts" in the jenkins pipeline Example
Back to consumer
- (8) Add "Can I Deploy" check in the jenkins pipeline Example
That's all!!! Your pact broker communication should work!
How the build/ci pipeline flow works
- Consumer changes the pact definition and pushes
- Jenkins will kick off the consumer build
- Consumer build will publish the new pact definition to pact broker
- Pact broker will kick off a provider build
- Provider build will verify pacts
While the provider build is running, the consumer build will check periodically if it's possible to deploy via canIDeploy (timeout can be specified)
- After checked with success
- The canIDeploy thread in the consumer will be green
- The consumer will be deployed
- If periodic checks finally failed (timeout is exceeded)
- The provider and after that the consumer needs to be re-built
- After checked with success