Is there a reason you're trying to mount the volum...
# pact-net
a
Is there a reason you're trying to mount the volume in general to
/var/lib
? I have a simpler version where I just mount it directly to root as
/pacts
. For comparison, I'm publishing contracts using Docker in ADO with:
Copy code
steps:
- task: DownloadPipelineArtifact@2
  displayName: Download artifact containing pacts
  inputs:
    artifactName: ${{ parameters.pactsArtifactName }}
    targetPath: $(Agent.TempDirectory)/pacts

- script: >
    docker run
    -e PACT_BROKER_TOKEN
    -v $(Agent.TempDirectory)/pacts:/pacts
    pactfoundation/pact-cli@sha256:ddefe0e43c3706884635a2642f2be366274679d7055f300ed92c4e384639ba0a
    broker publish
    /pacts
    --consumer-app-version ${{ parameters.version }}
    --branch ${{ parameters.branch }}
    --broker-base-url https://<company>.<http://pactflow.io|pactflow.io>
  displayName: Publish to Pactflow
  env:
    PACT_BROKER_TOKEN: $(SecretPactBrokerToken)
m
I've just tried using /pacts rather than /var/lib. Unfortunately it's still not working. I'm getting PactBroker:Client:Error - No pact files found
a
Your example showed an exact path to
/var/lib/pacts/createdcontacts/ConsumerService-ProviderService.json
, but have you tried just passing in the directory itself like I've done so that it basically would publish all contracts from the directory? So just pass in
/var/lib/pacts
without the filename. No idea if it would help, but that's at least one difference I spot between our solutions 👀
Since the error also says in plural "No pact files found" I was thinking if it expects the directory instead of the full path to a file.
m
I have tried just using the just the directory and the explicit file name. No luck. I am now trying the command on my local docker image and I am seeing the same error messages. I'm baffled. docker run --rm -v createdcontracts:/pacts xyz.azurecr.io/pact-cli:v1 broker publish /pacts -b="https://xyz.pactflow.io" -k="***" -a="1.0.0"
a
Can you try with the same image I've been using out of curiosity:
pactfoundation/pact-cli@sha256:ddefe0e43c3706884635a2642f2be366274679d7055f300ed92c4e384639ba0a
it's the 0.50.0.26 one from here (that I probably should update since there's newer ones available): https://hub.docker.com/r/pactfoundation/pact-cli/tags
m
Ok, will give it a try. Thanks
Same on 0.50.0.26 PactBroker:Client:Error - No pact files found
When running the publish command locally, should the volume arg -v be a full path or relative?
a
No idea, I'd assume both would work though 🤔. I don't currently even have Docker on my personal work laptop. I just threw that together that template I pasted and ran it directly in ADO to see that the pipelines work. I've been running the Pact tools just locally in WSL where I have both the Ruby & Rust CLIs installed.
m
OK, finally got it to work. I had to add additional tasks to my yml pipeline to pass the pact artifact between stages
🎉 1