Search code examples
gradlepactpact-jvmpact-broker

Unable to publish the 'Last Verified' status in PACT Broker


For microservices contract tests, am using PACT with gradle 4.4 and here is my build.gradle:

buildscript {
  repositories {
    mavenCentral()
 }
 dependencies {
     classpath 'au.com.dius:pact-jvm-provider-gradle_2.12:3.5.22'
  }
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: "au.com.dius.pact"


pact {

 serviceProviders {

    // You can define as many as you need, but each must have a unique name
    UserService {

        // All the provider properties are optional, and have sensible defaults (shown below)
        protocol = 'http'
        host = 'localhost'
        port = 8111
        project.version = "2.0.1"
        hasPactsFromPactBroker('http://10.100.198.200:8113')

        }
}            
  pact {
  publish {
  version = "2.0.1"
  pactDirectory = 'pacts' // defaults to $buildDir/pacts
        pactBrokerUrl = 'http://10.100.198.200:8113'

 }
 }
}

While am able to publish the pact files in the broker and able to see the dependency graphs, 'Last Verified' shows blank after running the pactVerify method. I saw some documentation around 'pact.verifier.publishResults=true' and tried to pass as gradle parameter, but I got an error message saying:

FAILURE: Build failed with an exception.

  • What went wrong: Your project is misconfigured, was expecting a 'pact' configuration in the build, but got a String with value '' instead. Make sure there is no property that is overriding 'pact'.

the gradle command I run is:

      ./gradlew test pactPublish 
      ./gradlew pactVerify -Ppact.verifier.publishResults=true

Please let me know what am I missing, the pact.verifier.publishResults is not accepted


Solution

  • The first thing is your Gradle config is invalid. There should only be one pact block. You have two. Remove the inner one with the publish block in it (but leave the publish block :-D).

    If that does not resolve your issue, have a look at https://github.com/DiUS/pact-jvm/issues/738 and see if any of the changes from the comments helps.