一、所需插件名稱web
Deploy to container Pluginshell
Jenkins SSH pluginapache
二、pom profiles配置緩存
<profiles> <profile> <activation> <activeByDefault>true</activeByDefault> </activation> <id>develop</id> <properties> <jdbc.username>root</jdbc.username> …… </properties> …… </profile> …… </profiles> <!--包含的資源目錄--> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <webResources> <resource> <filtering>true</filtering> <directory>src/main/webapp</directory> <includes> <include>**/*.xml</include> </includes> </resource> </webResources> </configuration> </plugin> </plugins> </build>
三、maven 打包參數 :clean install -P testtomcat
四、Deploy to container Plugin使用配置服務器
五、新建執行更新服務器的shell job app
#關閉指定端口號的tomcat netstat -antp |awk '/:9080/{print $NF}'|awk -F'/' '{print $1}'|xargs kill -9 #切換到tomcat目錄 cd /home/appuser/apache-tomcat-x/ #刪除tomcat日誌logs文件夾裏的所有文件 rm -fr logs/* #刪除tomcat jsp文件緩存 rm -rf work/Catalina/* #刪除上一次備份應用部署文件 rm -rf bak/*~ #刪除上一次備份應用war文件 rm -rf war/*~ #將應用移到bak文件夾備份 mv -fb webapps/w/x bak #將發佈的應用war移到war目錄下備份 mv -fb webapps/tomcat/x.war war #將發佈的應用移到指定的虛擬主機下 mv -fb webapps/tomcat/x webapps/w/ #啓動tomcat ./bin/startup.sh