Giter Site home page Giter Site logo

pactbroker-maven-plugin's Introduction

Pactbroker Maven Plugin

Pactbroker Maven Plugin integrates with PactBroker and allows to upload pacts created by consumer rsp download pacts that are verified against providers.

It also allows to use a git-repository instead of a PactBroker-instance as simplification so no additional infrastructure is needed.

Installation

add on-demand-repository (using https://jitpack.io/)

<pluginRepositories>
	<pluginRepository>
		<id>jitpack.io</id>
		<url>https://jitpack.io</url>
	</pluginRepository>
</pluginRepositories>

or install locally

git clone ...
cd pactbroker-maven-plugin
mvn install

##Usage

###Consumer

Configure plugin in your pom.xml using the upload-pacts goal:

<build>
  <plugins>
    <plugin>
      <groupId>com.github.warmuuh</groupId>
      <artifactId>pactbroker-maven-plugin</artifactId>
      <version>0.0.10</version>
      <executions>
        <execution>
          <id>upload-pacts</id>
          <phase>test</phase>
          <goals><goal>upload-pacts</goal></goals>
          <configuration>
            <brokerUrl>ssh://gitlab/pact-repo.git</brokerUrl>
            <pacts>${project.build.directory}/pacts</pacts>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

###Producer

Configure plugin in your pom.xml. This time, the download-pacts goal is used:

<build>
  <plugins>
    <plugin>
      <groupId>com.github.warmuuh</groupId>
      <artifactId>pactbroker-maven-plugin</artifactId>
      <version>0.0.10</version>
      <executions>
        <execution>
          <id>download-pacts</id>
          <phase>generate-resources</phase>
          <goals><goal>download-pacts</goal></goals>
          <configuration>
            <brokerUrl>ssh://gitlab/pact-repo.git</brokerUrl>
            <pacts>${project.build.testOutputDirectory}/pacts-dependents</pacts>
            <provider>provider</provider>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

###Having consumer and producer in a multi-module project Configure plugin at the parent pom

<build>
  <plugins>
      <plugin>
            <groupId>com.github.warmuuh</groupId>
            <artifactId>pactbroker-maven-plugin</artifactId>
            <version>0.0.10</version>
            <executions>
                <execution>
                    <goals>
                        <goal>upload-pacts</goal>
                    </goals>
                    <phase>none</phase>
                </execution>
                <execution>
                    <id>download-pacts</id>
                    <phase>none</phase>
                    <goals>
                        <goal>download-pacts</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
  </plugins>
</build>

At generate-test-resources phase the relevant provider pacts will be downloaded to the providerPacts directory to be able to verify provider behavior against consumers, meanwhile consumer pacts will be uploaded at the verify phase from the consumerPacts directory which was previously generated by tests. With this approach there is no need for profiles. A simple mvn clean install does the job.

<build>
  <plugins>
    <plugin>
      <groupId>com.github.warmuuh</groupId>
      <artifactId>pactbroker-maven-plugin</artifactId>
      <version>0.0.10</version>
          <executions>
              <execution>
                  <goals>
                      <goal>upload-pacts</goal>
                  </goals>
                  <phase>verify</phase>
                  <configuration>
                    <brokerUrl>ssh://gitlab/pact-repo.git</brokerUrl>
                    <pacts>${project.build.directory}/pacts</pacts>
                  </configuration>
              </execution>
              <execution>
                  <id>download-pacts</id>
                  <phase>generate-test-resources</phase>
                  <goals>
                      <goal>download-pacts</goal>
                  </goals>
                  <configuration>
                    <brokerUrl>ssh://gitlab/pact-repo.git</brokerUrl>
                    <pacts>${project.build.testOutputDirectory}/pacts-dependents</pacts>
                    <provider>provider</provider>
                  </configuration>
              </execution>
          </executions>
    </plugin>
  </plugins>
</build>

If you are using scala-pact from ITV to generate pacts than it generates separate pact file for all the tests. Before you upload it to the broker you might want to group and merge them based on the provider and customer name. Use mergePacts config element to force pact merge before upload to the broker

<build>
  <plugins>
    <plugin>
      <groupId>com.github.warmuuh</groupId>
      <artifactId>pactbroker-maven-plugin</artifactId>
      <version>0.0.10</version>
      <executions>
        <execution>
          <id>upload-pacts</id>
          <goals><goal>upload-pacts</goal></goals>
          <configuration>
            <brokerUrl>ssh://gitlab/pact-repo.git</brokerUrl>
            <pacts>${project.build.directory}/pacts</pacts>
            <mergePacts>true</mergePacts>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

To provide credentials when using git repository while uploading or downloading pacts, use the configuration sections as below:

    <configuration>
      <brokerUrl>https://github.com/pact-repo.git</brokerUrl>
      <pacts>target/pacts-dependents</pacts>
	  <provider>provider</provider>
      <username>user</username>
	  <password>password</password>
    </configuration>

To provide credentials when using a pact broker with HTTP basic auth, use the configuration sections as below:

    <configuration>
      <brokerUrl>https://yourbroker.pact.dius.com.au</brokerUrl>
      <pacts>target/pacts-dependents</pacts>
	  <provider>provider</provider>
      <username>user</username>
	  <password>password</password>
    </configuration>

you can also supply <insecure>true</insecure> to ignore certificate validation

pactbroker-maven-plugin's People

Contributors

amitmahajan78 avatar andreschaffer avatar bsayersatlassian avatar dervism avatar scho avatar warmuuh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pactbroker-maven-plugin's Issues

Pacts from broker are downloaded as HTML

Environment:

  • Broker with docker image dius/pact_broker:1.1.0, and also dius/pact-broker:2.0.0-beta

  • JDK 1.8.0_111

  • Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
    Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

  • Plugin configuration:

        <plugin>
            <groupId>com.github.warmuuh</groupId>
            <artifactId>pactbroker-maven-plugin</artifactId>
            <version>0.0.10</version>
            <configuration>
                <provider>foo</provider>
                <brokerUrl>http://localhost</brokerUrl>
            </configuration>
        </plugin>

In the broker, I have a pact with the provider 'foo', tagged with version 0.0.0.
When executing plugin, I have the following log:

[INFO] >>> pactbroker-maven-plugin:0.0.10:download-pacts (default-cli) > generate-test-resources @ provider >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ provider ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ provider ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< pactbroker-maven-plugin:0.0.10:download-pacts (default-cli) < generate-test-resources @ provider <<<
[INFO] 
[INFO] --- pactbroker-maven-plugin:0.0.10:download-pacts (default-cli) @ provider ---
[INFO] Downloading pact links from http://localhost/pacts/provider/foo/latest
[INFO] Downloading pact from http://localhost/pacts/provider/foo/consumer/foo_consumer/version/0.0.0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.435 s
[INFO] Finished at: 2017-05-02T13:20:19+02:00
[INFO] Final Memory: 28M/514M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.10:download-pacts (default-cli) on project provider: Failed to download pacts: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 14 -> [Help 1]

The cause is that the requests sent to the broker always have the header 'Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2' (I've seen that with a sniffer), so if possible, the broker returns the HTML view instead of the needed JSON.

In the code of BrokerRepositoryProvider.java, the connection has the right 'Content-Type' but 'Accept' is not defined, I don't know where that value comes.

No file is saved when downloading pacts

I have the pluging configured like following:

        <plugin>
            <groupId>com.github.warmuuh</groupId>
            <artifactId>pactbroker-maven-plugin</artifactId>
            <version>0.0.10</version>
            <configuration>
                <brokerUrl>http://localhost:80</brokerUrl>
                <tagName>latest</tagName>
                <provider>foo</provider>
                <pacts>target/pacts-downloaded</pacts>
            </configuration>
            <executions>
                <execution>
                    <id>download-pacts</id>
                    <phase>generate-resources</phase>
                    <goals><goal>download-pacts</goal></goals>
                </execution>
            </executions>
        </plugin>

When I execute mvn pactbroker:download-pacts, everything seems to be ok (log at the end), and the folder where the pacts should be downloaded is created, but its always empty.

The log prints the download url (http://localhost:80/pacts/provider/foo/latest/latest), and I've checked it's right with my browser, it downloads a valid file.

Am I doing something wrong?

Log:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building provider 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> pactbroker-maven-plugin:0.0.10:download-pacts (default-cli) > generate-test-resources @ provider >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ provider ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ provider ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] <<< pactbroker-maven-plugin:0.0.10:download-pacts (default-cli) < generate-test-resources @ provider <<<
[INFO] 
[INFO] --- pactbroker-maven-plugin:0.0.10:download-pacts (default-cli) @ provider ---
[INFO] Downloading pact links from http://localhost:80/pacts/provider/foo/latest/latest
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.549 s
[INFO] Finished at: 2017-04-28T13:48:19+02:00
[INFO] Final Memory: 25M/395M
[INFO] ------------------------------------------------------------------------

Release of 0.0.5

Hey there,

would you mind, releasing a new version? We are relying on the changes from the PRs. Currently, we use the snapshot version deployed to our company nexus instance.

Thanks for your help!

Cheers
Georg

Plugin not playing well downloading pacts from latest pact broker versions

Hi!

We're getting a json parsing error when downloading pacts from the latest pact broker versions (e.g. docker image dius/pact-broker:2.6.0-2).

com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 14
	at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505)
	at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1386)
	at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:531)
	at com.google.gson.stream.JsonReader.peek(JsonReader.java:414)
	at com.google.gson.JsonParser.parse(JsonParser.java:60)
	... 27 more

Unable to upload pact files to broker server

When using the maven plugin to upload pact files, it is throwing the below error:

[INFO] --- pactbroker-maven-plugin:0.0.9:upload-pacts (upload-pacts) @ micro-service-1 ---

[INFO] loading pacts from /Users/rashmi.patil/workspace/prod-engg/test-pact/pact/pact-junit-java/micro-service-1/target/pacts

[INFO] found pact file: Service1-Service2.json

[INFO] Uploading pact to http://localhost:8080/pacts/provider/Service2/consumer/Service1/version/1.0.0

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 12.814 s

[INFO] Finished at: 2016-09-26T13:58:40+05:30

[INFO] Final Memory: 21M/292M

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.9:upload-pacts (upload-pacts) on project micro-service-1: Failed to read pacts: Connection refused -> [Help 1]

Encountering issue while uploading pacts

I have the following configuration in my pom.xml

com.github.warmuuh pactbroker-maven-plugin 0.0.10 upload-pacts test upload-pacts https://github.com/pact-repo.git target/pacts SomeService user password

I get the following error when I try to run the upload-pacts goal

[INFO] loading pacts from target/pacts
[INFO] found pact file: AccessService-ScimService.json
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.770 s
[INFO] Finished at: 2017-11-03T22:47:50-04:00
[INFO] Final Memory: 16M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.10:upload-pacts (default-cli) on project access-service: Failed to read pacts: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.10:upload-pacts (default-cli) on project access-service: Failed to read pacts
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to read pacts
at com.github.wrm.pact.maven.UploadPactsMojo.execute(UploadPactsMojo.java:92)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 26 more
Caused by: java.lang.NullPointerException
at com.github.wrm.pact.maven.AbstractPactsMojo.createRepositoryProvider(AbstractPactsMojo.java:27)
at com.github.wrm.pact.maven.UploadPactsMojo.execute(UploadPactsMojo.java:88)
... 28 more

Issue downloading pact files from broker

Peeking into the code a bit, I see that CloseableHttpResponse response = createClient().execute(request); yields the following 406 error:

HttpResponseProxy{HTTP/1.1 406 Not Acceptable [Content-Length: 0, Connection: keep-alive, Status: 406 Not Acceptable, Date: Tue, 10 Jul 2018 20:05:59 GMT, X-Content-Type-Options: nosniff, Server: Webmachine-Ruby/1.5.0 Rack/1.3, X-Pact-Broker-Version: 2.24.0, X-Powered-By: Phusion Passenger 5.1.11] [Content-Length: 0,Chunked: false]}

However it seems that this code snippet works as intended:

CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(path);
CloseableHttpResponse response = httpclient.execute(httpGet);

I am not sure what the difference between the two function calls is. Any help would be appreciated.

Release 0.0.11

Thanks for merging #19

Please release these changes in next version of the plugin so we can start using them.

version upgrade to 0.0.13 did not work

I am getting following error i upgraded it's version
from
0.0.5
to
0.0.13

verifying a pact between coreDomainApi and legacyApi
[2021-11-24 08:46:26.229] boot - 12928 ERROR [main] --- ProviderVerifier: Failed to load pact file
groovy.json.JsonException: Unable to process file: target/pacts-dependents/some.json
at groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:153)
at groovy.json.JsonSlurper.parseFile(JsonSlurper.java:365)
at groovy.json.JsonSlurper.parse(JsonSlurper.java:348)
at au.com.dius.pact.model.PactReader.loadFile(PactReader.groovy:185)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at au.com.dius.pact.model.PactReader.loadPact(PactReader.groovy:28)
at au.com.dius.pact.model.PactReader.loadPact(PactReader.groovy)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at au.com.dius.pact.provider.ProviderVerifier.loadPactFileForConsumer(ProviderVerifier.groovy:118)
at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.groovy:79)
at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.groovy)
at au.com.dius.pact.provider.ProviderVerifier$runVerificationForConsumer$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)
at com.qmetric.legacy_api.acceptance.support.Contract$_verifyConsumerPact_closure1.doCall(Contract.groovy:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at groovy.lang.Closure.call(Closure.java:414)
at groovy.lang.Closure.call(Closure.java:430)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2040)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2025)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2066)
at org.codehaus.groovy.runtime.dgm$163.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at com.qmetric.legacy_api.acceptance.support.Contract.verifyConsumerPact(Contract.groovy:21)
at com.qmetric.legacy_api.acceptance.support.Contract$verifyConsumerPact.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at com.qmetric.legacy_api.acceptance.LegacyApiAsProviderForCoreDomainApiServiceContractTest.shouldHonourPacts(LegacyApiAsProviderForCoreDomainApiServiceContractTest.groovy:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:233)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:242)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:137)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.io.FileNotFoundException: target/pacts-dependents/coreDomainApi-legacyApi.json (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at groovy.util.CharsetToolkit.(CharsetToolkit.java:71)
at org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:1577)
at groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:147)
... 76 more
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 13.086

the configuration on this plugin is

com.github.warmuuh pactbroker-maven-plugin 0.0.13 https:/${pact brocker url} ${provider api url} download-pacts generate-resources download-pacts

"[ERROR] Failed to execute [...] upload-pacts on project consumer: Failed to read pacts: source" when pactBroker requires user & password

Hi. I have a working project, now I'm trying to change my pact broker to the one that requires a username and a password (I've created one with https://pact.dius.com.au/).

Unfortunately I keep getting an error message: Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.10:upload-pacts (default-cli) on project consumer: Failed to read pacts: source

You can find my settings and the full stack trace below. I can't see anything wrong with the config. But pact plugin is not able to establish the connection with my new pact broker. Is anything wrong with my config or is there a bug in the plugin?

BTW, error message is not very accurate, is it. It says "Failed to read pacts" while it actually failed to UPLOAD pacts. Maybe the plugin needs to read something first to then upload pacts, but for the end user it's really confusing. Could you do something about it pls?

My settings:

I've updated existing settings according to the description on the plugin page: https://github.com/warmuuh/pactbroker-maven-plugin
I've added <username> and <password> and upgraded plugin version from 0.0.5 to 0.0.10
The result is:

<plugin>
    <groupId>com.github.warmuuh</groupId>
    <artifactId>pactbroker-maven-plugin</artifactId>
    <version>0.0.10</version>
    <configuration>
        <brokerUrl>https://MY_P_BROKER.pact.dius.com.au</brokerUrl>
        <username>MY_USER</username>
        <password>MY_PASS</password>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>upload-pacts</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Full stack trace:

[ERROR] Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.10:upload-pacts (default-cli) on project consumer: Failed to read pacts: source -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.10:upload-pacts (default-cli) on project consumer: Failed to read pacts
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to read pacts
	at com.github.wrm.pact.maven.UploadPactsMojo.execute(UploadPactsMojo.java:92)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 19 more
Caused by: java.lang.NullPointerException: source
	at java.util.Objects.requireNonNull(Objects.java:228)
	at java.util.Scanner.<init>(Scanner.java:578)
	at com.github.wrm.pact.repository.BrokerRepositoryProvider.uploadPact(BrokerRepositoryProvider.java:111)
	at com.github.wrm.pact.repository.BrokerRepositoryProvider.uploadPacts(BrokerRepositoryProvider.java:40)
	at com.github.wrm.pact.maven.UploadPactsMojo.execute(UploadPactsMojo.java:89)
	... 21 more

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.