我正在尝试使用docker-maven-plugin(由spotify提供:https://github.com/spotify/docker-maven-plugin)使用Gitlab-CI构建一个docker镜像。
pom.xml
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<imageName>MY_REGISTRY/${project.artifactId}</imageName>
<imageTags>
<imageTag>latest</imageTag>
</imageTags>
<dockerDirectory>docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<serverId>my-registry</serverId>
<registryUrl>https://MY_REGISTRY/v2/</registryUrl>
</configuration>
<executions>
<execution>
<id>docker-build</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>docker-push</id>
<phase>deploy</phase>
<goals>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
以下是带有maven debug的完整版本:
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (docker-build) on project marktbeobachtung: Exception caught: org.bouncycastle.asn1.pkcs.PrivateKeyInfo cannot be cast to org.bouncycastle.openssl.PEMKeyPair -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (docker-build) on project marktbeobachtung: Exception caught
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
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:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
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:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
Caused by: org.apache.maven.plugin.MojoExecutionException: Exception caught
at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:141)
at com.spotify.docker.BuildMojo.execute(BuildMojo.java:86)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.lang.ClassCastException: org.bouncycastle.asn1.pkcs.PrivateKeyInfo cannot be cast to org.bouncycastle.openssl.PEMKeyPair
at com.spotify.docker.client.DockerCertificates.<init>(DockerCertificates.java:91)
at com.spotify.docker.client.DockerCertificates.<init>(DockerCertificates.java:57)
at com.spotify.docker.client.DockerCertificates$Builder.build(DockerCertificates.java:170)
at com.spotify.docker.client.DefaultDockerClient.fromEnv(DefaultDockerClient.java:1691)
at com.spotify.docker.AbstractDockerMojo.getBuilder(AbstractDockerMojo.java:146)
at com.spotify.docker.AbstractDockerMojo.buildDockerClient(AbstractDockerMojo.java:153)
at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:138)
... 22 more
当我使用Jenkins时,我没有收到任何错误。
mvn clean javadoc:javadoc javadoc:test-javadoc deploy -Psonar sonar:sonar
在Gitlab-CI中,我将maven分为4个阶段:
部署阶段失败,我执行此命令:
mvn deploy
我不知道如何解决这个问题,我们将非常感谢任何意见。