dubbo框架的web端(war)和server端(tar.gz)結合jenkins打包方式

一.web端程序,打包成war包java

jenkins配置mysql

1.項目名稱,舊文件處理配置git

 

2.參數構建配置github

 

3.源碼庫配置web

 

4.打包文件pom.xml配置及多環境打包傳參,此處傳參qa(表示打測試環境包,名稱自定義)spring

 

5.maven全局配置文件路徑sql

 

6.打包後執行操做shell

 

 

pom.xml配置apache

<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.jeck.danny</groupId>
                <artifactId>danny-cloud-parent</artifactId>
                <version>1.2.0-SNAPSHOT</version>
                <relativePath>../danny-cloud-parent</relativePath>
  </parent>

  <artifactId>test-web</artifactId> <packaging>war</packaging> <name>test-web</name>

<url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <scm> <connection>scm:svn:https://192.168.1.8/svn/test</connection> <developerConnection>scm:svn:https://192.168.1.8/svn/test</developerConnection> </scm> <dependencies> <dependency> <groupId>com.jeck.danny</groupId> <artifactId>danny-common</artifactId> </dependency> <dependency> <groupId>com.jeck.danny</groupId> <artifactId>danny-i18n</artifactId> <version>1.2.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.jeck.danny</groupId> <artifactId>danny-domain</artifactId> </dependency> <dependency> <groupId>com.jeck.danny</groupId> <artifactId>danny-user-sso</artifactId> <version>1.2.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.jeck.danny</groupId> <artifactId>danny-test-api</artifactId> <version>1.2.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.github.sgroschupf</groupId> <artifactId>zkclient</artifactId> <exclusions> <exclusion> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <exclusions> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> <exclusion> <artifactId>spring</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> </dependency> ... <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> ...//一大堆依賴略 </dependencies> <distributionManagement> <repository> <id>danny-releases</id> <name>danny-releases</name> <url>http://maven.danny.com.cn:8091/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>danny-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://maven.danny.com.cn:8091/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> <build> <finalName>test-web</finalName> <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-ssh</artifactId> <version>2.10</version> </extension> </extensions> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>8.1.16.v20140903</version> <configuration> <scanIntervalSeconds>3</scanIntervalSeconds> <stopPort>9988</stopPort> <stopKey>foo</stopKey> <webApp> <contextPath>/paicoin</contextPath> </webApp> <!-- 設置監聽目錄 --> <connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>8080</port> <maxIdleTime>60001</maxIdleTime> </connector> </connectors> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.5.3</version> <configuration> <tagBase>https://192.168.1.8/svn/test</tagBase> </configuration> </plugin> </plugins> </build> </project>

jenkins運行打包後,會在項目的target目錄下生成一個war文件api

 

 

二.server端程序,打包成tar.gz包

jenkins配置

前面配置和web端配置差很少

 

 

pom.xml配置

此處在pom.xml中調用了assembly.xml配置文件

先看pom.xml配置

<modelVersion>4.0.0</modelVersion>

        <parent>
                <groupId>com.danny.test</groupId>
                <artifactId>test-cloud-parent</artifactId>
                <version>1.2.0-SNAPSHOT</version>
                <relativePath>../test-cloud-parent</relativePath>
        </parent>

 <artifactId>test-service</artifactId> <packaging>jar</packaging>

  <name>test-service</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <scm>
                <connection>scm:svn:https://192.168.1.8/svn/test/tags/server/打包發佈/server/業務系統</connection>
  </scm>
  <dependencies>

      <dependency>
                        <groupId>com.danny.test</groupId>
                        <artifactId>test-common</artifactId>
      </dependency>

      <dependency>
                        <groupId>com.danny.test</groupId>
                        <artifactId>test-domain</artifactId>
      </dependency>

      <dependency>
                        <groupId>com.danny.test</groupId>
                        <artifactId>test-user-api</artifactId>
      </dependency>
      <dependency>
                        <groupId>com.danny.test</groupId>
                        <artifactId>test-paicoin-api</artifactId>
                        <version>1.2.0-SNAPSHOT</version>
      </dependency>
     <!--  <dependency>
                                   <groupId>com.danny.test</groupId>
                        <artifactId>test-user-sso</artifactId>
                        <version>1.2.0-SNAPSHOT</version>
      </dependency> -->
      <dependency>
                        <groupId>com.alibaba</groupId>
                        <artifactId>dubbo</artifactId>
          </dependency>

          <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
          </dependency>

           <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>jcl-over-slf4j</artifactId>
                </dependency>

                <dependency>
                        <groupId>ch.qos.logback</groupId>
                        <artifactId>logback-classic</artifactId>
                </dependency>
                <dependency>
                        <groupId>org.apache.poi</groupId>
                        <artifactId>poi</artifactId>
                        <version>3.13</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.poi</groupId>
                        <artifactId>poi-ooxml</artifactId>
                        <version>3.13</version>
                </dependency>

  </dependencies>



  <build>
       <resources>
                        <resource>
                                <directory>src/main/resources</directory>
                                <filtering>true</filtering>
                        </resource>
                </resources>

                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-compiler-plugin</artifactId>
                                <version>3.0</version>
                                <configuration>
                                        <source>1.7</source>
                                        <target>1.7</target>
                                        <encoding>UTF-8</encoding>
                                </configuration>
                        </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <version>2.4</version>
                                <configuration>
                                   <!-- 
                                                                                <includes>
                                                <include>*.properties</include>
                                                <include>**/*.xml</include>
                                        </includes>
                                        -->
                                        <excludes>
                                                <exclude>**/*.properties</exclude>
                                        </excludes>
                                </configuration>
                        </plugin>
                        <plugin>
                                <artifactId>maven-assembly-plugin</artifactId>
                                <executions>  <!--執行器 mvn assembly:assembly -->
                                        <execution>
                                                <id>make-assembly</id><!--名字任意 -->
                                                <phase>package</phase><!-- 綁定到package生命週期階段上 -->
                                                <goals>
                                                        <goal>single</goal><!-- 只運行一次 -->
                                                </goals>
                                                <configuration>
                                                        <finalName>${artifactId}</finalName>
                                                        <appendAssemblyId>false</appendAssemblyId>
                                                        <attach>false</attach>
                                                       <descriptors> <!--描述文件路徑 --> <descriptor>src/main/assembly/assembly.xml</descriptor> </descriptors>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-release-plugin</artifactId>
                                <version>2.5.3</version>
                                <configuration>
                                        <tagBase>https://192.168.1.8/svn/test/tags/server/打包發佈/server/業務系統</tagBase>
                                </configuration>
                        </plugin>
                </plugins>
        </build>

</project>

 

assembly.xml文件配置

<assembly>
        <id>assembly</id>
      <formats> <format>tar.gz</format> <!-- <format>zip</format> <format>dir</format> --> </formats>
        <includeBaseDirectory>true</includeBaseDirectory>
        <fileSets>
                <fileSet>
                        <directory>src/main/assembly/bin</directory>
                        <outputDirectory>bin</outputDirectory>
                        <fileMode>0755</fileMode>
                </fileSet>
                <!-- <fileSet> <directory>src/main/assembly/conf</directory> <outputDirectory>conf</outputDirectory> 
                        <fileMode>0644</fileMode> </fileSet> -->
                <fileSet>
                        <directory>src/main/resources/</directory>
                        <outputDirectory>conf</outputDirectory>
                        <filtered>true</filtered>
                        <includes>
                                <include>dubbo.properties</include>
                                <include>property.properties</include>
                        </includes>
                </fileSet>
                <!-- <fileSet> <directory>src/test/resources</directory> <outputDirectory>conf</outputDirectory> 
                        <fileMode>0644</fileMode> </fileSet> -->
        </fileSets>
        <dependencySets>
                <dependencySet>
                        <outputDirectory>lib</outputDirectory>
                </dependencySet>
        </dependencySets>
</assembly>

一樣jenkins運行打包後,會在項目的target目錄下生成一個tar.gz文件

 

注:

  setting.xml主要用於配置maven的運行環境等一系列通用的屬性,是全局級別的配置文件;而pom.xml主要描述了項目的maven座標,依賴關係,開發者須要遵循的規則,組織和licenses,以及其餘全部的項目相關因素,是項目級別的配置文件。

  一般一個項目可能還包含其餘的外部配置文件,或者自定義的shell腳本或者bat命令等,此時應該使用assemble命令來進行構建。assembly,即組合構建的意思,使用此插件能夠整合你想要的文件到最終的tar包中。

相關文章
相關標籤/搜索