2017-11-02 1 views
0

빌드하는 각 모듈에 대해 대상/myModule.ear을 생성하는 maven 빌드가 있습니다.젠킨스 - 다양한 귀로부터 tar.gz를 만들고 멀리 떨어진 서버에 전달하십시오.

은 내가 젠킨스 작업 만들려하십시오 tar.gz의에

2) 아카이브 모든 귀를 "클린 설치 MVN"

1)가 함께 프로젝트를 빌드를

3) 먼 서버

에 tar.gz의 전달 나는 젠킨스 아주 새로운 그래서 난 호 모르는입니다 2)와 3)을 할 w. 제가 생각해 낼 수있는 유일한 해결책은 스크립트를 만드는 것입니다.하지만 그렇게하면 젠킨스를 사용할 필요가 없습니다.

답변

1

war/jar가있는 상위 프로젝트와 전쟁을 감싸기위한 귀 프로젝트가 필요하고 tar.gz를 어셈블하기위한 배포 프로젝트가 필요합니다. 귀 프로젝트는 전쟁 프로젝트에 의존성을 가지고처럼 보이는

<?xml version="1.0" encoding="UTF-8"?> 
<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> 

    <groupId>com.greg</groupId> 
    <artifactId>ear-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 

    <properties> 
     <myproject.version>1.0-SNAPSHOT</myproject.version> 
    </properties> 

    <name>ear-example</name> 
    <modules> 
    <module>example-ear</module> 
    <module>example-war</module> 
    <module>distribution</module> 
    </modules> 

</project> 

: 같은

부모 보이는

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

    <parent> 
    <groupId>com.greg</groupId> 
    <artifactId>ear-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>example-ear</artifactId> 
    <packaging>ear</packaging> 

    <dependencies> 
    <dependency> 
     <groupId>com.greg</groupId> 
     <artifactId>example-war</artifactId> 
     <version>${project.version}</version> 
     <type>war</type> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
    <plugin> 
     <artifactId>maven-ear-plugin</artifactId> 
     <version>2.10.1</version> 
     <configuration> 
       <modules> 
         <webModule> 
           <groupId>com.greg</groupId> 
           <artifactId>example-war</artifactId> 
           <contextRoot>/appname</contextRoot> 
         </webModule> 
       </modules> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 

</project> 

배포 프로젝트는 다음과 같습니다

<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.greg</groupId> 
    <artifactId>ear-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>distribution</artifactId> 
    <packaging>pom</packaging> 

    <name>Distribution</name> 

    <dependencies> 
    <dependency> 
     <groupId>com.greg</groupId> 
     <artifactId>example-ear</artifactId> 
     <version>${project.version}</version> 
     <type>ear</type> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
     <plugin> 
     <artifactId>maven-assembly-plugin</artifactId> 
     <version>3.1.0</version> 
     <executions> 
      <execution> 
      <id>distro-assembly</id> 
      <phase>package</phase> 
      <goals> 
       <goal>single</goal> 
      </goals> 
      <configuration> 
       <descriptors> 
       <descriptor>src/assembly/assembly.xml</descriptor> 
       </descriptors> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
    </build> 

</project> 

조립을 .zml을 작성하는 .xml은 다음과 같습니다.

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> 

    <id>bin</id> 
    <formats> 
    <format>zip</format> 
    </formats> 
    <includeBaseDirectory>false</includeBaseDirectory> 
    <moduleSets> 
    <moduleSet> 
     <useAllReactorProjects>true</useAllReactorProjects> 
     <binaries> 
     <outputDirectory>modules/maven-assembly-plugin</outputDirectory> 
     <unpack>false</unpack> 
     </binaries> 
    </moduleSet> 
    </moduleSets> 
</assembly> 

배포 당신이 자신에게

+0

을해야 할 것 내가 그렇게하려고합니다 감사합니다! – Flyout

+1

나는 당신이 말했던 것처럼했고 그것은 매력처럼 작동합니다. 고맙습니다. – Flyout

관련 문제