Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
QMG-kazala opened this issue Nov 7, 2017 · 2 comments

Comments

@QMG-kazala
Copy link

QMG-kazala commented Nov 7, 2017

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
@niek1414
Copy link

niek1414 commented May 24, 2018

I had the same problem, the password and username are only used for git auth (GitRepositoryProvider) and not for the broker:
AbstractPactsMojo.java

 if (url.endsWith(".git")) {
            Optional<CredentialsProvider> credentialProvider = this.getCredentialsProvider(username, password);
            return new GitRepositoryProvider(url, this.getLog(), credentialProvider);
        } else {
            return new BrokerRepositoryProvider(url, consumerVersion, this.getLog());
        }

No credentials are given to the broker repository
EDIT: Oeps, this seems fixed in 0.0.12 (and possibly before) but to use a version above 0.0.10 the version needs to be updated.

@warmuuh
Copy link
Owner

warmuuh commented May 24, 2018

didnt saw that the pom versino is still set to 0.0.10. I bumped it to 0.0.13, please try with this version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants