pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Path to pact file with spaces leads to java.lang.Exception: Did not find any pact files for provider #563

Open viktorgt opened 6 years ago

viktorgt commented 6 years ago

pact-jvm-provider-spring_2.12 version: 3.5.7

This behavior gave me a headache, because it only occured on our jenkins quality gate build for the develop branch, which is named 'Develop quality gate'. By default, jenkins uses the name of the pipeline as working directory, which leads to the following path:

/var/jenkins_home/workspace/MyProject/Develop quality gate

For the multiple branch pipeline jenkins generates a name including the branch name and some random value:

/home/jenkins/workspace/rManagement_CI_myFeatureBranch-QPTVHWL7REKJQTUZIEBI3US7VMUTUAB4RK2JINTQR3DVYYE2UWKA

So the pipeline on the feature branch is OK, but after a merge you have no idea why its failing. We changed our jenkins configuration, but a fix is required.

uglyog commented 6 years ago

Could you kindly provide a bit more context: were you fetching the pact files using a @PactFolder annotation or from the pact broker? A stack trace would also be useful.

viktorgt commented 6 years ago
@RunWith(SpringRestPactRunner.class)
@Provider("order-management")
@PactFolder("pacts") 
public class PactPackGroupProviderTest {
...
}

Pacts are located here: src/test/resources/pacts/ So the path from above looks like: /var/jenkins_home/workspace/MyProject/Develop quality gate/src/test/resources/pacts/somecsonumer-order-management.json

java.lang.Exception: Did not find any pact files for provider order-management

at org.junit.runners.model.InitializationError.(InitializationError.java:38) at au.com.dius.pact.provider.junit.PactRunner.(PactRunner.java:90) at au.com.dius.pact.provider.junit.RestPactRunner.(RestPactRunner.java:14) at au.com.dius.pact.provider.spring.SpringRestPactRunner.(SpringRestPactRunner.kt:15) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

uglyog commented 6 years ago

Version 3.5.9 has been released