Matthieu SALETA
05/16/2023, 9:40 AMbranch information but it does not work properly. Here is the command that was executed by the action :
mvn au.com.dius.pact.provider:maven:4.1.11:publish -Dpact.broker.url=<https://XXXX.pactflow.io> -Dpact.broker.token=*** -Dpact.broker.authenticationScheme=*** -Dpact.publish.consumer.branchName=feat/UTO-706_contract-testing
But in Pactflow the branch has been set with the 93/merge that is the merge branch generated by Github on Pull Request.
Is there a known problem ou am I doing something wrong ?
Thanks for your help!Timothy Jones
05/16/2023, 9:51 AMmaven-surefire-plugin in your xml?Timothy Jones
05/16/2023, 9:53 AMpact.publish.consumer.branchName or PACT_PUBLISH_CONSUMER_BRANCHNAME set to "93/merge"?
(If no, you could also try setting those environment variable to your desired value, as a workaround)Matthieu SALETA
05/16/2023, 9:54 AMMatthieu SALETA
05/16/2023, 9:56 AM-Dpact.publish.consumer.branchName=feat/UTO-706_contract-testing
And that is precisely what it does not work.Timothy Jones
05/16/2023, 9:59 AMpact.publish.consumer.branchName
or
PACT_PUBLISH_CONSUMER_BRANCHNAMETimothy Jones
05/16/2023, 10:00 AMMatthieu SALETA
05/16/2023, 1:00 PMuglyog
pact.provider.branch, you can see all the properties here: https://github.com/pact-foundation/pact-jvm/blob/master/docs/system-properties.mdTimothy Jones
05/16/2023, 11:32 PMMatthieu SALETA
05/23/2023, 8:15 AMBranch name for the provider from the version control system to record when publishing verification results.
But I'm not publishing verification result, i'm publishing the pact from the consumer so i don't think it will work with this property 😕uglyog
Matthieu SALETA
05/23/2023, 9:01 AMprivate fun branchName(config: PublishConfiguration): JsonValue {
return config.branchName.ifNullOrEmpty {
lookupEnvironmentValue("pact.publish.consumer.branchName")
}.toJson()
}
https://github.com/pact-foundation/pact-jvm/blob/master/core/pactbroker/src/main/kotlin/au/com/dius/pact/core/pactbroker/PactBrokerClient.kt#L721
So it is the good one.
It executes : https://github.com/pact-foundation/pact-jvm/blob/master/core/support/src/main/kotlin/au/com/dius/pact/core/support/Utils.kt#L185
/**
* Looks up a value from the environment, first by looking for the JVM system property with the key, then
* looking for an environment variable with the key, then looking for the snake-cased version of the key as an
* environment variable.
*/
fun lookupEnvironmentValue(key: String): String? {
return lookupEnvironmentValue(key, { k: String -> System.getProperty(k) }, { k: String -> System.getenv(k) })
}
/**
* Looks up a value from the environment, first by looking for the JVM system property with the key, then
* looking for an environment variable with the key, then looking for the snake-cased version of the key as an
* environment variable.
*/
fun lookupEnvironmentValue(
key: String,
sysLookup: (key: String) -> String?,
envLookup: (key: String) -> String?
): String? {
var value: String? = sysLookup(key)
if (value.isNullOrEmpty()) {
value = envLookup(key)
}
if (value.isNullOrEmpty()) {
value = envLookup(snakeCase(key))
}
return value
}
In my case, it will do :`System.getProperty("pact.publish.consumer.branchName")` so the only way that the value could be wrong, is that the branchName field is already set in the Mojo : https://github.com/pact-foundation/pact-jvm/blob/master/provider/maven/src/main/kotlin/au/com/dius/pact/provider/maven/PactPublishMojo.kt#L40Matthieu SALETA
05/23/2023, 9:40 AM4.1.11 .... facepalm2
I've just checked the documentation and it says : Including the consumer branch when publishing [min versions 4.1.33/4.2.19/4.3.4]
I have no excuse, sorry for the inconvenience...