question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tags are not published with the Gradle plugin when using providerTags

See original GitHub issue

According to the documentation you can publish tags when verifying a contract via providerTags. I’ve found that specifying providerTags in the pact Gradle task does not work

pact {
    def gitSha = "git rev-parse --short HEAD".execute().text.trim()
    logger.lifecycle("gitSha: " + gitSha)

    // apply pact-specific properties https://docs.pact.io/implementation_guides/jvm/provider/gradle/#project-properties
    System.setProperty("pact.showStacktrace", "true");
    System.setProperty("pact.verifier.ignoreNoConsumers", "true");
    broker {
        pactBrokerUrl = 'https://pact-broker.docker.savagebeast.com'
    }
    reports {
        defaultReports() // adds the standard console output
        markdown // report in markdown format
        json // report in json format
        console
    }
    serviceProviders {
        catalog {
            terminateProviderTask = killGretty
            // assume that when pact verification is run, the port is not specified via the command line
            port = "$grettyPort"
            fromPactBroker {
                // specify the tags we want to verify here
                // https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/
                selectors = latestTags('master', 'mobile-test', 'prod', 'dr')
                providerTags = ['foo']
                providerVersion = { gitSha }
                if (gitBranch == 'master') {
                    enablePending = true // enable pending pacts support
                }
            }
        }
    }

When I run ./gradlew pactVerify -i -PdevDB -Ppact.verifier.publishResults=true -d the request with providerTags is null and the pact verification result is not tagged in the pact-broker:

16:53:58.426 [DEBUG] [au.com.dius.pact.provider.ProviderClient] Making request for provider au.com.dius.pact.provider.gradle.GradleProviderInfo@63e27c4e[providerVersion=build_agfshzjdd1dkne35s7bt3ouk3$_run_closure24$_closure42$_closure43$_closure44$_closure45@1615af63,providerTag=<null>,providerTags=<null>,brokerConfig=PactBrokerConsumerConfig(selectors=[ConsumerVersionSelector(tag=master, latest=true, consumer=null, fallbackTag=null), ConsumerVersionSelector(tag=mobile-test, latest=true, consumer=null, fallbackTag=null), ConsumerVersionSelector(tag=prod, latest=true, consumer=null, fallbackTag=null), ConsumerVersionSelector(tag=dr, latest=true, consumer=null, fallbackTag=null)], enablePending=false, providerTags=[foo]),project=project ':catalog',name=catalog,protocol=http,host=localhost,port=64683,path=/,startProviderTask=<null>,terminateProviderTask=task ':catalog:killGretty',requestFilter=<null>,stateChangeRequestFilter=<null>,createClient=<null>,insecure=false,trustStore=<null>,trustStorePassword=changeit,stateChangeUrl=<null>,stateChangeUsesBody=true,stateChangeTeardown=false,isDependencyForPactVerify=true,verificationType=REQUEST_RESPONSE,packagesToScan=[],consumers=[ConsumerInfo(name='Pact between hestia (6a00bddc) and catalog', stateChange=null, stateChangeUsesBody=true, packagesToScan=[], verificationType=null, pactSource=BrokerUrlSource(url=https://pact-broker.docker.savagebeast.com/pacts/provider/catalog/consumer/hestia/pact-version/aa83c5731bb25aa8e840dbc64bd4062eaa133159, pactBrokerUrl=https://pact-broker.docker.savagebeast.com, attributes={}, options={}, tag=null, result=PactBrokerResult(name=Pact between hestia (6a00bddc) and catalog, source=https://pact-broker.docker.savagebeast.com/pacts/provider/catalog/consumer/hestia/pact-version/aa83c5731bb25aa8e840dbc64bd4062eaa133159, pactBrokerUrl=https://pact-broker.docker.savagebeast.com, pactFileAuthentication=[], notices=[VerificationNotice(when=before_verification, text=The pact at https://pact-broker.docker.savagebeast.com/pacts/provider/catalog/consumer/hestia/pact-version/aa83c5731bb25aa8e840dbc64bd4062eaa133159 is being verified because it matches the following configured selection criteria: latest pact for a consumer version tagged 'dr', latest pact for a consumer version tagged 'master', latest pact for a consumer version tagged 'mobile-test', latest pact for a consumer version tagged 'prod' (all have the same content))], pending=false, tag=null, wip=false, usedNewEndpoint=true)), pactFileAuthentication=[], notices=[VerificationNotice(when=before_verification, text=The pact at https://pact-broker.docker.savagebeast.com/pacts/provider/catalog/consumer/hestia/pact-version/aa83c5731bb25aa8e840dbc64bd4062eaa133159 is being verified because it matches the following configured selection criteria: latest pact for a consumer version tagged 'dr', latest pact for a consumer version tagged 'master', latest pact for a consumer version tagged 'mobile-test', latest pact for a consumer version tagged 'prod' (all have the same content))], pending=false, wip=false), ConsumerInfo(name='Pact between graphql (1896a2ce) and catalog', stateChange=null, stateChangeUsesBody=true, packagesToScan=[], verificationType=null, pactSource=BrokerUrlSource(url=https://pact-broker.docker.savagebeast.com/pacts/provider/catalog/consumer/graphql/pact-version/34c9b0ea66c203af2897e2f9f8ec0772f60697aa, pactBrokerUrl=https://pact-broker.docker.savagebeast.com, attributes={}, options={}, tag=null, result=PactBrokerResult(name=Pact between graphql (1896a2ce) and catalog, source=https://pact-broker.docker.savagebeast.com/pacts/provider/catalog/consumer/graphql/pact-version/34c9b0ea66c203af2897e2f9f8ec0772f60697aa, pactBrokerUrl=https://pact-broker.docker.savagebeast.com, pactFileAuthentication=[], notices=[VerificationNotice(when=before_verification, text=The pact at https://pact-broker.docker.savagebeast.com/pacts/provider/catalog/consumer/graphql/pact-version/34c9b0ea66c203af2897e2f9f8ec0772f60697aa is being verified because it matches the following configured selection criteria: latest pact for a consumer version tagged 'dr', latest pact for a consumer version tagged 'master', latest pact for a consumer version tagged 'mobile-test', latest pact for a consumer version tagged 'prod' (all have the same content))], pending=false, tag=null, wip=false, usedNewEndpoint=true)), pactFileAuthentication=[], notices=[VerificationNotice(when=before_verification, text=The pact at https://pact-broker.docker.savagebeast.com/pacts/provider/catalog/consumer/graphql/pact-version/34c9b0ea66c203af2897e2f9f8ec0772f60697aa is being verified because it matches the following configured selection criteria: latest pact for a consumer version tagged 'dr', latest pact for a consumer version tagged 'master', latest pact for a consumer version tagged 'mobile-test', latest pact for a consumer version tagged 'prod' (all have the same content))], pending=false, wip=false)]]:
16:53:58.427 [DEBUG] [au.com.dius.pact.provider.ProviderClient]         method: POST

When I run ./gradlew pactVerify -i -Ppact.verifier.publishResults=true -Dpact.provider.tag=foo -PdevDB -d, I see the following entry in the gradle output and the pact verification result is tagged in the pact-broker:

17:00:47.531 [DEBUG] [au.com.dius.pact.core.pactbroker.PactBrokerClient] Pushed tag foo for provider catalog and version 3b305ae4

The project I’m using is configured with the following:

au.com.dius.pact.provider:gradle:4.1.20'
------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          11.0.9 (AdoptOpenJDK 11.0.9+11)
OS:           Mac OS X 10.15.7 x86_64

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ianrhamiltoncommented, Oct 11, 2021

@uglyog I don’t think this is specifically related to Gradle. I also have this same problem with maven using version 4.1.28. Unfortunately, this is the latest version I can use due to my project being a java 8 project. Other projects within my company that are using the latest version do not have this issue, but like I say given I have to use a Java 8 supported version the issue persists.

1reaction
uglyogcommented, Nov 13, 2021

I’m just stating the reason for the current behaviour, but it is not ideal and needs to be fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publishing Plugins to the Gradle Plugin Portal
This section will show you how to use the Plugin Publishing Plugin to publish plugins to the Gradle Plugin Portal using a convenient...
Read more >
Gradle plugin to verify a provider | Pact Docs
Gradle plugin for verifying pacts against a provider. ... Sets the provider tag to push before publishing verification results (can use a ...
Read more >
gradle-release-plugin no tags but generate version on CI
I would like to build on CI (jenkins) and tell it NOT TO TAG in git but perform the rest of the steps,...
Read more >
Gradle Enterprise Gradle Plugin User Manual
Using the Gradle Enterprise connector; Using Gradle's built-in ... Build scans are not automatically published after applying the plugin.
Read more >
Gradle tips and recipes - Android Developers
Gradle and the Android plugin for Gradle provide a flexible way to compile, ... You can use the sourceSets block in the module-level...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found