Maven部署位置与下载位置

时间:2015-09-28 21:01:50

标签: maven jenkins continuous-integration pom.xml nexus

我在设置问题时遇到了问题;我的最终目标是从一个连接中提取工件(我将其称为Nexus1)并部署到另一个连接(Nexus2),两个托管在具有不同域的不同位置。

这是我的settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<distributionManagement>
  <repository>
     <id>deployment</id>
     <name>Internal Releases</name>
     <url>http://Nexus2/content/repositories/releases/</url>
  </repository>
  <snapshotRepository>
     <id>deployment</id>
     <name>Internal Releases</name>
     <url>http://Nexus2/content/repositories/snapshots/</url>
  </snapshotRepository>
</distributionManagement>
  <mirrors>
    <mirror>
      <id>company-central</id>
      <name>CompanyCentral</name>
      <url>http://Nexus1/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>default-repositories</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>core-releases</id>
          <url>http://Nexus1/content/repositories/core-release</url>
          <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>core-snapshots</id>
          <url>http://Nexus1/content/repositories/core-snapshot</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </repository>
        <repository>
          <id>releases</id>
          <url>http://Nexus1/content/repositories/releases</url>
          <releases>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>snapshots</id>
          <url>http://Nexus1/content/repositories/snapshots</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
        </repository>
      </repositories>
    </profile>
    <profile>
         <id>inject-liferay-properties</id>
         <properties>
           <liferay.auto.deploy.dir.val>/Users/dmadathil/Documents/Portal/workspace/X-Portal-11.0.0/bundles/deploy</liferay.auto.deploy.dir.val>
           <liferay.app.server.deploy.dir.val>/Users/dmadathil/Documents/Portal/workspace/X-Portal-11.0.0/bundles</liferay.app.server.deploy.dir.val>
           <liferay.app.server.lib.global.dir.val>/Users/dmadathil/Documents/Portal/workspace/X-Portal-11.0.0/bundles/tomcat-7.0.42/lib</liferay.app.server.lib.global.dir.val>
           <liferay.app.server.portal.dir.val>/Users/dmadathil/Documents/Portal/workspace/X-Portal-11.0.0/bundles/tomcat-7.0.42/webapps/ROOT</liferay.app.server.portal.dir.val>
         </properties>
     </profile>    
 </profiles>
 <activeProfiles>
   <activeProfile>inject-liferay-properties</activeProfile>
 </activeProfiles>
</settings>

这是我的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.company</groupId>
        <artifactId>super-pom</artifactId>
        <version>1.1.0</version>
    </parent>

    <artifactId>covlogs</artifactId>
    <version>0.0.2-SNAPSHOT</version>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>

            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>

        <dependency>
            <groupId>com.company.platform.group.client</groupId>
            <artifactId>group-client</artifactId>
        </dependency>

        <dependency>
            <groupId>com.company.platform.user.client</groupId>
            <artifactId>user-client</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>

    </dependencies>


    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>1.2.5.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <version>1.2.5.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>com.company.core</groupId>
                <artifactId>slf4j-bom</artifactId>
                <version>1.7.12</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>com.company.platform.group.client</groupId>
                <artifactId>group-client</artifactId>
                <version>1.1.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>com.company.platform.user.client</groupId>
                <artifactId>user-client</artifactId>
                <version>1.0.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.9</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>20141113</version>
            </dependency>

        </dependencies>
    </dependencyManagement>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.4.201502262128</version>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
        <!--<repository>
            <id>core-releases</id>
            <url>http://Nexus1/content/repositories/core-release</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>core-snapshots</id>
            <url>http://Nexus1/content/repositories/core-snapshot</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
        <repository>
            <id>releases</id>
            <url>http://Nexus1/content/repositories/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>snapshots</id>
            <url>http://Nexus1/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>-->
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>
</project>

我面临的问题是,每次构建项目时,它仍然会尝试上传到Nexus1而不是Nexus2 !!

编辑:这是来自Jenkins&#39;的示例错误消息。输出控制台:

ERROR: Failed to deploy artifacts: Could not transfer artifact com.company:covlogs:jar:0.0.2-20150928.201829-1 from/to snapshots (http://Nexus1/content/repositories/core-snapshot/): Failed to transfer file: http://Nexus1/content/repositories/core-snapshot/com/company/covlogs/0.0.2-SNAPSHOT/covlogs-0.0.2-20150928.201829-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.

我还是maven的新手,我不确定出了什么问题。我现在已经开了几天了。

非常感谢任何帮助!

EDIT2:我已经采取了步骤,我已经添加了<distributionManagement>块,希望它可以解决问题,但这不起作用。

我还将maven-deploy-plugin添加到pom.xml中,但这也没有做任何事情。

EDIT3:对于Jenkins,我使用Maven Release插件来设置我希望将工件部署到的位置:

enter image description here

0 个答案:

没有答案