Is it possible to record deployments and undeploym...
# pact-broker
s
Is it possible to record deployments and undeployments via curl? If yes - how? If no, it would be very nice to not have to install the entire CLI for that simple action in CD pipelines.
āœ… 1
m
s
Yep! see
Neat! Does it also work for open source pact broker? I wanted to test it out manually, but I get
Copy code
{
  "error": "The requested document was not found on this server."
}
I am providing the consumer name, consumer version and an existing environment as path parameters.
https://<broker_url>/pacticipants/<consumer-name>/versions/<consumer-version>/deployed-versions/environment/test
What about other CLI calls like publishing pacts, or calling can-i-deploy?
We are running various stages in different containers. So far we had to install the CLI in one container during the build, to publish pacts and run can-i-deploy, but publishing the build to environments happens in another container, where we'd have to install it again. šŸ™‚ Just peculiarities of our pipeline.
šŸ‘ 1
Ah, my bad, it needs environment ID
šŸ‘ 1
Can I record undeployment via API though? šŸ¤” Don't see it in the API docs
Even though the docs states, that recording undeployment is generally not needed, because reocrding the next deployment overrides pervious one, that's not what we need it for. We need to record undeployment if the deployment fails or gets aborted. 1. Deploy to testing environement. record deployment for
test
2. Deploy to beta environment. record deployment for
beta
3. Deployment gets aborted for any reason, this triggers automatic rollbacks for beta and test In those automatic rollbacks is where we would like to run pact undeploy. Is this the expected approach or is there an alternative way to go about this?
If this is not possible, perhaps we can record deployment with environment "rollback" or something 🤷
@Matt (pactflow.io / pact-js / pact-go), do you know?
m
It might not be documented, but it should be possible
Use the CLI command to perform an undeployment with the
--verbose
command, and then use that info to determine how to proceed (it will show the verb, path, headers and payload)
s
Ah, good idea, I will try that
I tested the undeployment out, but it seems like it does not really work with rollback. Here is our flow. 1. Deploy version 123 to
test
2. Deploy version 123 to
beta
3. Deploy version 123 to
prod
4. Deployment complete At this point, the versions should be as follows, right? • test - 123 • beta - 123 • prod - 123 Now someone makes another deployment 1. Deploy version 456 to
test
2. Deploy version 456 to
beta
3. uh-oh, the developer noticed a bug. Aborting the deployment, rolling back 4. Rolling back version 456 in
beta
5. Rolling back version 456 in
test
What I expected to happen, is that the versions in pact broker would be as follows: • test - 123 • beta - 123 • prod - 123 ... since they all rolled back.. What happened, when using record-undeployment though, was: • prod - 123 there were no versions marked with
test
or
beta
anymore in pact broker...
šŸ¦† - I guess when we roll back, we can get the version we are rolling back to ourselves and just record another deployment on top of it