Hi all, I am trying to configure the can-i-deploy ...
# pact-broker
p
Hi all, I am trying to configure the can-i-deploy job in my gitlab project. I wanted to know about what I need to put for the following args: 1. _"pacticipant" (_<Placeholder-1>) 2. _"version" (_<Placeholder-2>) 3. _"to" (_<Placeholder-3>) Here is my gitlab script.
Copy code
pact-can-i-deploy:
  image: pactfoundation/pact-cli:latest
  stage: pact-can-i-deploy
  tags: [linux-dind]
  dependencies:
    - pact-publish
  script:
    - "pact-broker can-i-deploy
         --pacticipant <Placeholder-1>
         --version <Placeholder-2>
         --to <Placeholder-3>
         --broker-base-url $PACT_BROKER_BASE_URL
         --broker-token $PACT_BROKER_API_TOKEN"
I have gone through the previous chats present on slack for this, but no luck, so posting here. Here is how my matrix is looking like:
👍 1
m
pacticipant = the application you want to deploy
(e.g. “VNR Consumer” or “CNE Producer”)
version = the version of the application you are going to deploy (e.g. 1.0.0 in your table)
to = the environment you want to deploy to “e.g. Production”
see howtonirvana
s
See this page on the steps to creating an effective contract-testing setup https://docs.pact.io/pact_nirvana. (This workshop demonstrates those principles in action: https://docs.pactflow.io/docs/workshops/ci-cd/)
âś… 1
p
Hey @Matt (pactflow.io / pact-js / pact-go) Thanks for the above resources for cicd implementation. I configured the pipeline for can-i-deploy job. For pacticipant, I added the following - CNE Producer (See can-i-deploy script screenshot) But I am getting error saying : Error making request to https://<ourname>.pactflow.io/matrix status=400 {"errors":["Pacticipant Producer not found"]} (see screenshot below) Here the weird thing is its saying Pacticipant Producer instead of CNE Producer. Does this have something to do with the name?
Error screenshot :
m
When you pass arguments to commands in a shell, you must escape things that have spaces in them, otherwise they are considered additional arguments
The value for
--pacticipant
should be
"CNE Producer"
âś… 1
p
That's what I was missing, thank you! 🙌
👍 1
@Matt (pactflow.io / pact-js / pact-go) For Can-I-Deploy. My understanding is that if the pact is in : Verified state, Can-I-Deploy says YES Unverified state, Can-I-Deploy says NO Failed state, Can-I-Deploy says NO Is this correct statement? I am seeing some results different from my understanding of this job, so wanted to know.
m
It’s not as simple as that, but in general “yes”. It entirely depends on the parameters being sent to
can-i-deploy
. It may be verified, but if one of the applications needed is not deployed to a target environment (and you us the
--to-environment
flag) than it will fail.
p
My matrix is looking like this. (See ss below) But when I run my pact-can-i-deploy script (Script ss below) It tells me Yes for deploy. My understanding is that it should say No. Can you please help me understand what I may be doing wrong in this? ================================== Also, How can I use Pact Cli locally to get outputs to commands like $ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to-environment ENVIRONMENT
m
Is there a reason you're using tags and not branches/environments?
To run it locally, you can run the same commands as you're running on CI. You can use the docker image or CLI
Howtocli
p
Hey Matt, we are using branches here only. We don't have any environments setup for this project yet as we are in initiation phase. I still don't understand why my can-i-deploy works when the pact is in unverified state