使用Maven插件失败将Docker映像推送到Nexus

时间:2019-11-28 12:11:27

标签: docker nexus

我正在尝试使用maven插件将Docker映像推送到Nexus。 Docker映像是使用Spotify插件创建的

我的./m2/settings.xml文件中有

<servers>
  <server>
        <id>nexus</id>
        <username>usr</username>
        <password>pass</password>
    </server>
  </servers> 

我的pom.xml如下所示

...  
      <properties>
            <java.version>1.8</java.version>
            <docker.image.prefix>newems</docker.image.prefix>
            <nexus.url>http://urlnexus</nexus.url>
            <nexus.prefix>urlnexus</nexus.prefix>
        </properties>


    <distributionManagement>
        <snapshotRepository>
            <id>nexus</id>
            <url>${nexus.url}</url>
        </snapshotRepository>
    </distributionManagement>

     ....
    <build>
       <plugins>
          <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
              <executions>
                <execution>
                  <goals>
                    <goal>repackage</goal>
                    <goal>build-info</goal>
                  </goals>
                </execution>
            </executions>                        
         </plugin>       


        <plugin>
            <groupId>org.sonatype.plugins</groupId><!-- para que funcione con el nexus -->
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.4</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>nexus</serverId>
              <nexusUrl>${nexus.url}</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
        </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <!--version>3.1.1</version-->
            <executions>
               <execution>
                  <id>unpack</id>
                  <phase>package</phase>
                  <goals>
                     <goal>unpack</goal>
                  </goals>
                  <configuration>
                     <artifactItems>
                        <artifactItem>
                           <groupId>${project.groupId}</groupId>
                           <artifactId>${project.artifactId}</artifactId>
                           <version>${project.version}</version>
                        </artifactItem>
                     </artifactItems>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>dockerfile-maven-plugin</artifactId>
            <version>1.4.10</version>
            <executions>
                <execution>
                    <id>deploy</id>
                    <goals>
                        <goal>build</goal>
                        <goal>push</goal>
                    </goals>
                </execution>
            </executions>            
            <configuration>
               <repository>${nexus.prefix}/${docker.image.prefix}/${project.artifactId}</repository>
               <imageName>${nexus.prefix}/${docker.image.prefix}/${project.artifactId}</imageName>
               <contextDirectory>.</contextDirectory>
               <tag>${project.version}</tag>
              <pullNewerImage>false</pullNewerImage>  
              <useMavenSettingsForAuth>true</useMavenSettingsForAuth>             
               <resources>
                  <resource>
                     <targetPath>/</targetPath>
                     <directory>${project.build.directory}</directory>
                     <include>${project.build.finalName}.jar</include>
                  </resource>
               </resources>
            </configuration>  
         </plugin>
         <plugin>
            <!--skip deploy (this is just a test module) -->
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
               <skip>true</skip>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

执行mvn deploy命令时,出现以下错误消息

Uploading to nexus: http://urlnexus/xxxx/test-rest-service/0.0.1-SNAPSHOT/test-rest-service-0.0.1-20191128.115339-1-docker-info.jar

[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.4:deploy (injected-nexus-deploy) on project test-rest-service: Failed to deploy artifacts: Could not find artifact xxx:test-rest-service:jar:docker-info:0.0.1-20191128.115339-1 in nexus ( http://urlnexus/) -> [Help 1]

我看到它在罐子中添加了日期和时间,但是有什么原因吗? 我在做什么错了?

0 个答案:

没有答案