HI, I have a consumer and a provider. Both are us...
# pactflow
r
HI, I have a consumer and a provider. Both are using pact-jvm and the gradle pact plugin to run the tests and publish it to pactflow. this is our gradle configuration:
Copy code
tasks {
  withType(Test::class) {
    useJUnitPlatform()
    systemProperty("pact_do_not_track", true)
    systemProperty("pactbroker.url", System.getenv()["PACTFLOW_URL"] ?: findProperty("pactflow.broker.url") as String)
    systemProperty("pactbroker.auth.token", System.getenv()["PACTFLOW_TOKEN_READWRITE"] ?: findProperty("pactflow.broker.token") as String)
    systemProperty("pact.verifier.publishResults", System.getenv()["PACTFLOW_VERIFIER_PUBLISH_RESULTS"] ?: findProperty("pact.verifier.publishResults") as String)
    systemProperty("pact.provider.version", project.version)
  }

  named("pactPublish").configure {
    dependsOn(check)
  }

  named("publish").configure {
    dependsOn("pactPublish")
  }
}

pact {
  broker {
    pactBrokerUrl = System.getenv()["PACTFLOW_URL"] ?: findProperty("pactflow.broker.url") as String
    pactBrokerToken = System.getenv()["PACTFLOW_TOKEN_READWRITE"] ?: findProperty("pactflow.broker.token") as String
  }
  publish {
//    pactDirectory = '/pact/dir' // defaults to $buildDir/pacts
  }
}
We use pactPublish also in feature branches:
Copy code
./gradlew clean pactPublish -Dpact.publish.consumer.version=${{ github.sha }} -D=pact.publish.consumer.branchName=${{ github.head_ref	}} --no-daemon --info --stacktrace
To then verify new pacts we currently just run the normal build of the provider with
pact.verifier.publishResults=true
We now ran into the problem several times that the feature branch published a pact which never got verified. We think it is because between publish and verify the main branch also published a pact, which the provider then verifies. I looked a bit into it and we found something like a selector where you can put your feature branches in the configuration, but we would just like to verify ALL pact version from all the branches we have in the system. any idea how we can configure our build so it asks the broker for more pacts?
✅ 1
m
This might be best asked in #C9UN99H24. The answer is docs.pact.io/selectors, possibly WIP/Pending pacts also (docs.pact.io/wip, docs.pact.io/pending). See also the CI/CD workshop, I think it addresses the problems you’re describing (howtolearn). But you’ll need to translate to Pact JVM specific code
👍 1
s
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops