Jenkins + maven + git 多環境自動化部署java
打包和tomcat部署都是放在maven中,pom文件以下:
<build>
<finalName>admin</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<!-- 資源根目錄排除各環境的配置,使用單獨的資源目錄來指定 -->
<excludes>
<exclude>local/*</exclude>
<exclude>dev/*</exclude>
<exclude>uat/*</exclude>
<exclude>demo/*</exclude>
<exclude>release/*</exclude>
</excludes>
</resource>
<resource>
<!-- Jenkins傳參,environment設置對應參數 -->
<directory>src/main/resources/${environment}</directory>
</resource>
</resources>
<plugins>
<!-- 編譯環境設置,若是安裝了多個JDK,最好指定一下編譯版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- tomcat部署 -->git
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>apache
<configuration>
<url>http://${serverAddress}/manager/text</url>
<server>tomcat</server>
<username>username</username>
<password>password</password>
<update>true</update>
<path>/admin</path>
</configuration>tomcat
</plugin>
</plugins>
</build>maven