spotify / docker-maven-plugin

INACTIVE: A maven plugin for Docker
Apache License 2.0
2.67k stars 575 forks source link

Authentication Failure When pushing to Registry During Release:Deploy #370

Closed robertnosburn closed 6 years ago

robertnosburn commented 6 years ago

Description

I have a project that is using the plugin. The plugin will build a docker image during the install phase and will push to my docker registry on the deploy stage. I am using the option true. My credentials are defined in the settings file.

In normal operation, from my Jenkins box this runs fine - images are build and pushed to my remote docker registry.

When this happens as part of the the release process, I get the following message: [INFO] [ERROR] unauthorized: Could not find robot with username: ipit+ipitrobot and supplied password

Note: that the username is correctly picked up from the server definitions in settings.xml.

How to reproduce

Build a simple project to create a docker image using the plugin, that uses "useMavenSettingsForAuth" Configure credentials in settings.xml

Perform a maven release:prepare and release:perform

What do you expect

[Describe what do you expect to happen]

Expected behavior is for the docker image to be uploaded to the remote registry

Actual result: unauthorized error as above, plus exception below [INFO] [ERROR] unauthorized: Could not find robot with username: ipit+ipitrobot and supplied password. [INFO] [WARNING] An attempt failed, will retry 1 more times [INFO] org.apache.maven.plugin.MojoExecutionException: Could not push image [INFO] at com.spotify.plugin.dockerfile.PushMojo.execute(PushMojo.java:90) [INFO] at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute(AbstractDockerMojo.java:246) [INFO] at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute(AbstractDockerMojo.java:235) [INFO] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) [INFO] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) [INFO] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) [INFO] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) [INFO] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) [INFO] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) [INFO] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) [INFO] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) [INFO] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) [INFO] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) [INFO] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) [INFO] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) [INFO] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) [INFO] at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) [INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [INFO] at java.lang.reflect.Method.invoke(Method.java:498) [INFO] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) [INFO] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) [INFO] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) [INFO] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) [INFO] Caused by: com.spotify.docker.client.exceptions.DockerException: unauthorized: Could not find robot with username: ipit+ipitrobot and supplied password. [INFO] at com.spotify.plugin.dockerfile.LoggingProgressHandler.handleError(LoggingProgressHandler.java:105) [INFO] at com.spotify.plugin.dockerfile.LoggingProgressHandler.progress(LoggingProgressHandler.java:63) [INFO] at com.spotify.docker.client.ProgressStream.tail(ProgressStream.java:74) [INFO] at com.spotify.docker.client.DefaultDockerClient.push(DefaultDockerClient.java:1291) [INFO] at com.spotify.docker.client.DefaultDockerClient.push(DefaultDockerClient.java:1271) [INFO] at com.spotify.plugin.dockerfile.PushMojo.execute(PushMojo.java:88) [INFO] ... 24 more

Software:

Full backtrace

[INFO] [ERROR] unauthorized: Could not find robot with username: ipit+ipitrobot and supplied password.
[INFO] [WARNING] An attempt failed, will retry 1 more times
[INFO] org.apache.maven.plugin.MojoExecutionException: Could not push image
[INFO]  at com.spotify.plugin.dockerfile.PushMojo.execute(PushMojo.java:90)
[INFO]  at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute(AbstractDockerMojo.java:246)
[INFO]  at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute(AbstractDockerMojo.java:235)
[INFO]  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[INFO]  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
[INFO]  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[INFO]  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[INFO]  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
[INFO]  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
[INFO]  at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[INFO]  at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[INFO]  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
[INFO]  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
[INFO]  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
[INFO]  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
[INFO]  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[INFO]  at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO]  at java.lang.reflect.Method.invoke(Method.java:498)
[INFO]  at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[INFO]  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[INFO]  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[INFO]  at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] Caused by: com.spotify.docker.client.exceptions.DockerException: unauthorized: Could not find robot with username: ipit+ipitrobot and supplied password.
[INFO]  at com.spotify.plugin.dockerfile.LoggingProgressHandler.handleError(LoggingProgressHandler.java:105)
[INFO]  at com.spotify.plugin.dockerfile.LoggingProgressHandler.progress(LoggingProgressHandler.java:63)
[INFO]  at com.spotify.docker.client.ProgressStream.tail(ProgressStream.java:74)
[INFO]  at com.spotify.docker.client.DefaultDockerClient.push(DefaultDockerClient.java:1291)
[INFO]  at com.spotify.docker.client.DefaultDockerClient.push(DefaultDockerClient.java:1271)
[INFO]  at com.spotify.plugin.dockerfile.PushMojo.execute(PushMojo.java:88)
[INFO]  ... 24 more
ccjoelm commented 6 years ago

I had a similar problem and found that if I put a clear text password (not ideal) in the settings.xml it worked, but if I use an encrypted password (mvn --encrypt-password), then if fails.